Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on having a form pop up when a y/n box is clicked

Status
Not open for further replies.

kuebs

Technical User
Mar 6, 2002
15
US
I have a form that I want opened when a y is clicked in a y/n box. This subform would allow them to fill in details of the incident. I have a button to close the form, but can't get anything to work to have it open automatically.

Also, I would like it if this subform could present information from the previous form. Just one field, the sales order number field, but I don't know how to make that type of look up funciton. Thanks.
 
The following code was written on the fly, so it might need to be tweaked. You should get the overall idea of how to do it though.

Dim Response
Dim rst as RecordSet
Dim strOrderNum as String

Response = MsgBox("Fill in details of incident?", vbYesNo) as vbYesNo
If Response = vbYes then
DoCmd.Open ("2ndFormName") 'Opens 2nd Form
'Following Code sets a label called lblOrderNum equal to the Sales Order Number
set rst = Me.RecordSetClone
rst.BookMark = Me.BookMark
strOrderNum = rst.[Field name of the Sales order number]
'Use a string convert function if the field is not text
Forms![2ndForm]![lblOrderNum].Value = strOrderNum
doCmd.close 'if you want to close the 1st form
Set rst = Nothing
rst.Close
end if
 
Thank you very much, I will try this. I do have some dumb questions about this. Where do I put this code? How do I set the check box so that it starts this code?
 
Doh. I miss read your question earlier. I thought you were talking about a msgbox u wanted to pop up. Anyway, place this code in the ON CLICK event of the y/n check box. (and tweak the code accordingly)

Dim rst as RecordSet
Dim strOrderNum as String

If Me![Name of the check box goes here].Value = True Then

DoCmd.Open ("2ndFormName") 'Opens 2nd Form
'Following Code sets a label called lblOrderNum equal to the Sales Order Number
set rst = Me.RecordSetClone
rst.BookMark = Me.BookMark
strOrderNum = rst.[Field name of the Sales order number]
'Use a string convert function if the field is not text
Forms![2ndForm]![lblOrderNum].Value = strOrderNum
doCmd.close 'if you want to close the 1st form
Set rst = Nothing
rst.Close
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top