Douglas J. Steele wrote:
> Since you're checking for a string value, you need quotes around the value.
> Since you're running the code in the module associated with the form, and
> since the control is on that form, you can use Me! instead of Forms!Clients:
>
> If Me!Condition = "GPM" Then
>
> I think that should solve the error you're getting.
>
> Jeff Conrad has a list of references pointing to references to books at
> http://home.bendbroadband.com/conrad...ces.html#Books
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Data" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello Experts,
> >
> > I need help.
> >
> > First question: I have a main form (Clients) which allows user to
> > select from a list of client ID's. A number of textboxes or fields get
> > filled up. Now one of these textboxes is called Condition or the
> > condition field. I now press a command buttopn which opens the
> > orientation form.
> > In the orientation form, I want to display records based on the text
> > in the Condition field in the Clients form.
> >
> > Here is copy of my code(I placed in form_load event of the
> > orientation form).
> > I don't know where to put it in the orientation_click event(command
> > button on clients form) or in the form_load event for the orientation
> > form.
> >
> >
Hello David,
Thanks
But someone suggested another way, I don't know where to put the code
though.
tina wrote:
> well, i probably wouldn't filter (restrict) the records in the 2nd form's
> Load event. since you're filtering based on data entered in a control in the
> 1st form, it's easier to refer to that control from within that form; i'd
> use the WHERE argument of the DoCmd.OpenForm action, in the Click event
> procedure of the command button in the 1st form, as
> If Me!Condition = "GPM" Then
> DoCmd.OpenForm "OrientationFormName", , , _
> "[Orientation Session Number]<=2"
> Else
> DoCmd.OpenForm "OrientationFormName"
> End If
> substitute the correct form name, of course. note that the above places
> quotes around "GPM" on the assumption that it is a text value in the 1st
> form's control.
> hth
Thanks Tina.
Altough I am not sure why the code's not working. I placed it in the
right location?
Private Sub cmdOrientation_Click()
If Me!Condition = "GPM" Then
DoCmd.OpenForm "Orientation", , , _
"[Orientation Session number]<=2"
Else
DoCmd.OpenForm "Orientation"
End If
'On Error GoTo Err_cmdOrientation_Click
' Dim stDocName As String
' Dim stLinkCriteria As String
' stDocName = "Orientation"
' DoCmd.OpenForm stDocName, , , stLinkCriteria
'Exit_cmdOrientation_Click:
' Exit Sub
'Err_cmdOrientation_Click:
' MsgBox Err.Description
' Resume Exit_cmdOrientation_Click
End Sub