Opening subsequest form on a specific value

G

Guest

Hi
On my first form I have a drop-down box and I want if user selects specific
value, access opens my second from, I tried following code but not working:

DoCmd.OpenForm "prc frm", , , , , , Reason_for_visit = [Procedure]
my second from field on first form specific
value
 
G

Guest

Hi

For the example you gave the cod would be something like

If (Forms!MainForm!SubForm!ListBox = "SomeText ") Then
DoCmd.OpenForm "Query_Bookings_4Pks_DropOff", acNormal, "",
"[FieldNameOnFormOrReport]=[Forms]![MainForm]![SubForm].[Form]![FieldName]",
acEdit, acNormal
End If



Basically you can use the on Click event of your list box for many criteria
- something like this

Private Sub ListBoxName_Click()
If (Forms!FormName!ListBoxName = "Something1") Then
DoCmd.OpenReport "ReportName", acViewNormal, "",
"SetCriteriaIfWantedHereâ€
End If
If (Forms!FormName!ListBoxName = "Something2") Then
DoCmd.OpenForm "FormName", acViewNormal, "", "SetCriteriaIfWantedHereâ€
End If
If (Forms!FormName!ListBoxName = "Something1") Then
DoCmd.OpenReport "ReportName", acViewNormal, "",
"SetCriteriaIfWantedHereâ€
End If
Etc
Etc
etc
End Sub

The criteria would be something ike this – if you need to restrict the form
/ report that want to open – you could use a ield on the form the set the
filter

Hope this helps
 
G

Guest

ooops

If (Forms!MainForm!SubForm!ListBox = "SomeText ") Then
DoCmd.OpenForm "FormName", acNormal, "",
"[FieldNameOnFormOrReport]=[Forms]![MainForm]![SubForm].[Form]![FieldName]",
acEdit, acNormal
End If


I know - I know - LoL. Code is all mad anyway. They don't use on star trek


--
Wayne
Manchester, England.
Enjoy whatever it is you do


Wayne-I-M said:
Hi

For the example you gave the cod would be something like

If (Forms!MainForm!SubForm!ListBox = "SomeText ") Then
DoCmd.OpenForm "Query_Bookings_4Pks_DropOff", acNormal, "",
"[FieldNameOnFormOrReport]=[Forms]![MainForm]![SubForm].[Form]![FieldName]",
acEdit, acNormal
End If



Basically you can use the on Click event of your list box for many criteria
- something like this

Private Sub ListBoxName_Click()
If (Forms!FormName!ListBoxName = "Something1") Then
DoCmd.OpenReport "ReportName", acViewNormal, "",
"SetCriteriaIfWantedHereâ€
End If
If (Forms!FormName!ListBoxName = "Something2") Then
DoCmd.OpenForm "FormName", acViewNormal, "", "SetCriteriaIfWantedHereâ€
End If
If (Forms!FormName!ListBoxName = "Something1") Then
DoCmd.OpenReport "ReportName", acViewNormal, "",
"SetCriteriaIfWantedHereâ€
End If
Etc
Etc
etc
End Sub

The criteria would be something ike this – if you need to restrict the form
/ report that want to open – you could use a ield on the form the set the
filter

Hope this helps



--
Wayne
Manchester, England.
Enjoy whatever it is you do


Ramtin said:
Hi
On my first form I have a drop-down box and I want if user selects specific
value, access opens my second from, I tried following code but not working:

DoCmd.OpenForm "prc frm", , , , , , Reason_for_visit = [Procedure]
my second from field on first form specific
value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top