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

Find match in recordset and populate value in another txtbox

Status
Not open for further replies.

CTOROCK

Programmer
May 14, 2002
289
US
In Access 2000!

I have a form that has a combo box pulling a container # value from a table field. the table has the fields Vessel, Container, & Cartons. On my form (unbound) I would like when cmbbox_lostfocus to look back in the table and find the the vessel and cartons for that record and populate the appropriate fields on my form. this is what I've tried:

Dim StrContainer As String
Dim Db As Database
Dim Rst As Dao.Recordset
Dim StrVessel As String

Set Db = CurrentDb
Set Rst = Db.OpenRecordset("Tbl_Container Schedule")
StrContainer = CmbContainer.Value
Rst.FindFirst StrContainer
StrVessel = Rst.Fields("vessel").Value
'MsgBox StrVessel
Rst.Close
TxtVessel.value = strvessel,


But I get an error on the find first. Do I need to set an index? how to make index container field?
Can anyone help? Thanks! "The greatest risk, is not taking one."
 
Hi CTOROCK,

FindFirst needs criteria to work on in the form of a WHERE clause (without the WHERE), so I think you'll need to change your line to something like ..

Code:
RSt.FindFirst "Container = """ & StrContainer & """"

Enjoy,
Tony
 
It says that the operation is not supported for this type of object.???? do you know what this means?

thanks! "The greatest risk, is not taking one."
 
Hi,

Yes, I didn't spot that! The various Finds don't work on table-type recordsets (the default) so change your open to ..

Code:
Set Rst = Db.OpenRecordset("Tbl_Container Schedule",
Code:
dbOpenDynaset
Code:
)

Enjoy,
Tony
 
Hey! Thanks a lot Tony! "The greatest risk, is not taking one."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top