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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set rs syntax help 1

Status
Not open for further replies.

topwaya

Technical User
May 4, 2005
150
US
Hi,

I have a form that I want to check a table to see if it has any matching fields (WinTyp and WinD) WinTyp is a text field and WinD is a date field. I can't get the syntax right for "set rs"

Code:
Private Sub Search_Click()
  Me.Visible = False

Dim rs As Recordset
Set db = CurrentDb

Set rs = db.OpenRecordset("Select WinTyp, WinD from tblWin where (WinTyp = 'WALK') AND (WinD = " &
       Forms!fdlgPickWalkWinners!TxtStart & ""))

If Not rs.EOF And Not rs.BOF Then

   MsgBox ("Winner's Already Picked!  Check Your Start Date!")

Else
  MsgBox ("adding winner")
   DoCmd.OpenQuery "qppWALKWinners", acNormal, acEdit
   DoCmd.CLOSE acQuery, "qppWALKWinners"

End If




End Sub

Any help is appreciated!
 
Perhaps this ?
Set rs = db.OpenRecordset("SELECT WinTyp,WinD FROM tblWin WHERE WinTyp='WALK' AND WinD=#" & Format(Forms!fdlgPickWalkWinners!TxtStart, "yyyy-mm-dd") & "#")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Works like a charm!!

Thank You Thank You Thank You!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top