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

Lookup record in table and poulate a txtbox with value

Status
Not open for further replies.

CTOROCK

Programmer
May 14, 2002
289
0
0
US
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 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.
Can anyone help? THanks! "The greatest risk, is not taking one."
 
The problem is probably in the sytax. The syntax for recorsets are a huge pain. One thing may work one time and then not another. Try using
Rst.FindFirst CmbContainer or
Rst.FindFirst("CmbContainer")
This may or may not work.
Good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top