|
Prev: Auto-Fill a Form
Next: Relationships and lookup tables.
From: John W. Vinson on 14 Jul 2008 01:41 On Sun, 13 Jul 2008 21:53:01 -0700, jerseygirl54 <jerseygirl54(a)discussions.microsoft.com> wrote: Thanks. You need a THEN, just as the error message suggested. Try Dim strCriteria As String 'only do the search if a name has been selected If Not IsNull(Me.[cboOfficer]) Then 'build criterion for search strCriteria = "[Officer ID]=" & Me.[cboOfficer] ' This assumes that Officer ID is a Number datatype ' if it is Text instead use ' strCriteria = "[Officer ID]='" & Me.[cboOfficer] & "'" 'open form filtered to selected person DoCmd.OpenForm "frmOfficerRoster", WhereCondition:=strCriteria 'close dialogue form DoCmd.Close acForm, Me.Name Else 'otherwise inform user MsgBox "No officer selected.", vbInformation, "Invalid Operation": End If -- John W. Vinson [MVP]
From: jerseygirl54 on 14 Jul 2008 17:52 I don't have an error any more, BUT...(for testing purposes) I entered part of a name. It then asks me for an officer ID, which one would not have if they are searching by name. I don't enter a number, then I get a list of possible matches. Problem is that I am unable to select any name from the list. I have to reenter the name, spelled correctly in order for it to pull it up. Also, if you misspell a name or enter a name that is not on the list, it does not give notification (message box) suggesting that you might have spelled the name wrong as there is no such name in the list. "John W. Vinson" wrote: > On Sun, 13 Jul 2008 21:53:01 -0700, jerseygirl54 > <jerseygirl54(a)discussions.microsoft.com> wrote: > > Thanks. You need a THEN, just as the error message suggested. Try > > Dim strCriteria As String > > 'only do the search if a name has been selected > If Not IsNull(Me.[cboOfficer]) Then > 'build criterion for search > strCriteria = "[Officer ID]=" & Me.[cboOfficer] > ' This assumes that Officer ID is a Number datatype > ' if it is Text instead use > ' strCriteria = "[Officer ID]='" & Me.[cboOfficer] & "'" > > 'open form filtered to selected person > DoCmd.OpenForm "frmOfficerRoster", WhereCondition:=strCriteria > > 'close dialogue form > DoCmd.Close acForm, Me.Name > Else > 'otherwise inform user > MsgBox "No officer selected.", vbInformation, "Invalid Operation": > > End If > -- > > John W. Vinson [MVP] >
From: jerseygirl54 on 17 Jul 2008 14:49
Whoo Hoo! Got it workin'. Thank you for all your help! "John W. Vinson" wrote: > On Sun, 13 Jul 2008 21:53:01 -0700, jerseygirl54 > <jerseygirl54(a)discussions.microsoft.com> wrote: > > Thanks. You need a THEN, just as the error message suggested. Try > > Dim strCriteria As String > > 'only do the search if a name has been selected > If Not IsNull(Me.[cboOfficer]) Then > 'build criterion for search > strCriteria = "[Officer ID]=" & Me.[cboOfficer] > ' This assumes that Officer ID is a Number datatype > ' if it is Text instead use > ' strCriteria = "[Officer ID]='" & Me.[cboOfficer] & "'" > > 'open form filtered to selected person > DoCmd.OpenForm "frmOfficerRoster", WhereCondition:=strCriteria > > 'close dialogue form > DoCmd.Close acForm, Me.Name > Else > 'otherwise inform user > MsgBox "No officer selected.", vbInformation, "Invalid Operation": > > End If > -- > > John W. Vinson [MVP] > |