Hi, I have a form with 4 pages. On page 2, I have a combobox that is tied to an external DBF table with 3 fields (code, obs, and test). When the user selects an item from the list, the DBF table's code value is stored in the combobox. Now I have a textbox on page 4 that I want to be autopopulated with a value based on the combobox's selected item. So if a single record in the DBF table is CP, CarPatrol, Test1 then when the user selects CP (code field) for the combobox, I want Test1 (test field) to autopopulate in the textbox on page 4. I am able to open the DBF table, find the record based on the combobox entry and store the "CP" and "Test1" values into variables and display them in a messagebox, but I can't get "Test1" to show up in the textbox. The following code is what I have so far. It is being called from the combobox's OnSelChanged event.Any suggestions on what I'm missing?Thanks,CharlotteOption Explicit
'autopopulate a second field based on entry in first field
Sub AutoPop
Dim objDBF, strCode, strTest, i , strObs, strLoc
strObs= Layers("camera_stn.shp").Forms("EDITFORM").Pages("PAGE2").Controls("obs").value 'user selected combo box
strLoc= Map.Layers("camera_stn.shp").Forms("EDITFORM").Pages("PAGE4").Controls("loc_desc").value 'autopopulate this field based on combo box selection
Set objDBF = Application.CreateAppObject("recordset")
objDBF.Open "L:\GPS\Trimble_base\luObsTest.dbf", 1 'open the external DBF table used for combobox list
objDBF.MoveFirst 'go to first record in DBF table
For i=0 to objDBF.RecordCount-1
strCode = objDBF.Fields("CODE").Value 'store value from CODE field
strTest= objDBF.Fields("TEST").Value 'store value from TEST field
If strObs=strCode then 'compare value user selected from combobox list to the 1st CODE value from the DBF table
strLoc=strTest 'if 1st CODE value = user selection then put the TEST value in the textbox on page 4...
Else
objDBF.MoveNext '...otherwise go to the next record in the DBF table
End If
Next
msgbox ("CODE = " & strCode & vbnewline & "TEST = " & strLoc) 'message box returns DBF values being stored as variables
objDBF.Close
Set objDBF = Nothing
End Sub