Minggu, 11 Oktober 2015

Re: [MS_AccessPros] Problems with FindFirst and Where statement

 

Peter-


The names of your fields imply they are numbers, not text.  If that is the case, then you need:

rstSTATISTICS.FindFirst "[numHOTELID] = " & strHOTELID & " And [numAGENTID] = " & strAGENTID 


John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On Oct 11, 2015, at 2:50 PM, pwfora@gmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Hello All,


I am using Access 2010


I have 3 tables:

- tblHOTELS contains hotel details (key = numHOTELID)

- tblAGENTS contains agent/partner detaisl (key = numAGENTID)

- The third table, tblSTATISTICS, contains information about production in each hotel by the individual agents. The table contains fields numHOTELID and numAGENTID to reference with the respective tables.


When I read the input data (from another table), I need to check if this particular agent has already booked this hotel. If they have, I update the record - otherwise I create a new record.


I have now problem looking for a record using one key. But I have not managed to create the "where clause" for two keys. 



       strHOTELID = rstHOTELS![numHOTELID]

       strAGENTID = rstAGENTS![numAGENTID]

'

       rstSTATISTICS.FindFirst "[numHOTELID] = '" & strHOTELID & "'" And "[numAGENTID] = '" & strAGENTID & "'"

       

       If rstSTATISTICS.NoMatch Then

rstSTATISTICS.addnew

...

Else

rstSTATISTICS.edit

....

       End If


I have tried in many different ways but either end up with error or not reading anything or the right thing.


Any guidance is highly appreciated.


Cheers.



Peter



__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar