G
Guest
Hi
I just read in the help file "Setting it to No by using Visual Basic is
equivalent to clicking Remove Filter/Sort on the Records menu"
the default for my form is DataEntry=True. I would like to set a Toggle when
the form is open already so that if the search box i have on the form has
criteria, then form.recordsource = myQuery (generated in VBA), otherwise i
want it to stay blank and only show a new entry but nothing else. i am
pasting in the code, if anybody has some input please help.
there may something about filters i can create, but i am not sure.
thanks,
sam
Code:
strSQL = "SELECT myTbl.* FROM myTbl "
bolCondition = False
If Not IsNull(Me.IDChoice) Then
strTempSQL = "WHERE myTbl.ID = " & Me.IDChoice
bolCondition = True
End If
If Not IsNull(Me.txtDateChoice) Then
If bolCondition = False Then
strTempSQL = " Where myTbl.DateWorked= #" & Me.txtDateChoice & "#"
Else
strTempSQL = strTempSQL & " And myTbl.DateWorked= #" &
Me.txtDateChoice & "#"
End If
bolCondition = True
End If
If Not IsNull(Me.AChoice) Then
If bolCondition = False Then
strTempSQL = " Where myTbl.AgencyID= " & Me.AChoice
Else
strTempSQL = strTempSQL & " And myTbl.AID= " & Me.AChoice
End If
bolCondition = True
End If
If Not IsNull(strTempSQL) Then
Me.DataEntry = False
Else
Me.DataEntry = True
End If
strSQL = strSQL & strTempSQL & " ORDER BY myTbl.DateWorked DESC;"
Me.RecordSource = strSQL
Me.Requery
I just read in the help file "Setting it to No by using Visual Basic is
equivalent to clicking Remove Filter/Sort on the Records menu"
the default for my form is DataEntry=True. I would like to set a Toggle when
the form is open already so that if the search box i have on the form has
criteria, then form.recordsource = myQuery (generated in VBA), otherwise i
want it to stay blank and only show a new entry but nothing else. i am
pasting in the code, if anybody has some input please help.
there may something about filters i can create, but i am not sure.
thanks,
sam
Code:
strSQL = "SELECT myTbl.* FROM myTbl "
bolCondition = False
If Not IsNull(Me.IDChoice) Then
strTempSQL = "WHERE myTbl.ID = " & Me.IDChoice
bolCondition = True
End If
If Not IsNull(Me.txtDateChoice) Then
If bolCondition = False Then
strTempSQL = " Where myTbl.DateWorked= #" & Me.txtDateChoice & "#"
Else
strTempSQL = strTempSQL & " And myTbl.DateWorked= #" &
Me.txtDateChoice & "#"
End If
bolCondition = True
End If
If Not IsNull(Me.AChoice) Then
If bolCondition = False Then
strTempSQL = " Where myTbl.AgencyID= " & Me.AChoice
Else
strTempSQL = strTempSQL & " And myTbl.AID= " & Me.AChoice
End If
bolCondition = True
End If
If Not IsNull(strTempSQL) Then
Me.DataEntry = False
Else
Me.DataEntry = True
End If
strSQL = strSQL & strTempSQL & " ORDER BY myTbl.DateWorked DESC;"
Me.RecordSource = strSQL
Me.Requery