Minggu, 11 Oktober 2015

[MS_AccessPros] Problems with FindFirst and Where statement

 

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: pwfora@gmail.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

.

__,_._,___

Tidak ada komentar:

Posting Komentar