howto access another table for search/update

  • Thread starter Thread starter Harry van Rijn
  • Start date Start date
H

Harry van Rijn

I am in the current event of a form.
If a NewRec is there I want to access a table order_numbers in
order to search for the last ordernumber in a year (order_number has
2 field: year(=prim key), ordernumber).
But I cannot execute the seek, findrecord or findfirst method.
Or the error message says: method not available, parameter not ok.

I want to search a table for some key, and then update the found
record with som value.
 
Sorry, I'v found the solution allready.
(But I had to ask, because I have no documentation of access)

private sub find_ordernumber
Dim MyDB
Dim MyTable

Set MyDB = CurrentDb
Set MyTable = MyDB.Openrecordset("order_numbers")

MsgBox MyTable.ordernumber ' = ok

MyTable.Index = "PrimaryKey" ' PrimaryKey seems to be important
MyTable.Seek "=", "2004" ' seek/search for key='2004'

MsgBox MyTable.volgnummer ' found value ok
end sub
 
Back
Top