Your combo should position the recordset to make the selected record the
current record. Then you you put in the missing information at that time.
Here is an example of how to use a combo to postion to a selected record.
Use the combo's After Update event:
Dim rst AS Recordset
Set rst = Me.RecordsetClone
rst.FindFirst "[SomeField] = '" & Me.MyCombo & "'"
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing
Now you are postiioned on the selected record. Note the above code does not
deal with values in the combo that are not in the table. You use the Not In
List event for that. To get the the Not In List to fire, you have to set the
Limit To List property of the combo to Yes.
Dim rst As Recordset
If MsgBox(NewData & " Is Not In The Attribute Table " & vbNewLine _
& "Do you want to add it", _
vbInformation + vbYesNo, "Not Found") = vbYes Then
CurrentDb.Execute ("INSERT INTO CISAttributeTable (ACTIVITY) " _
& "VALUES ('" & NewData & "');"), dbFailOnError
Me.Requery
Set rst = Me.RecordsetClone
rst.FindFirst "[Activity] = '" & NewData & "'"
Me.Bookmark = rst.Bookmark
Set rst = Nothing
Me.txtDescription.SetFocus
Response = acDataErrAdded
Else
Me.cboActivity.Undo
Response = acDataErrContinue
End If
JamesHall said:
Just Binding to the field does nothing because it doesn;t know which record
to put it into. how do i get it to know what record has been selected by the
combo?
thanks
:
Bind the text box to a field in the recordset.
:
I think you may hae misunderstod what i am asking for. I have a record of a
job and i am trying to put the finish date and time it this jobs record.
Using my cascading combos, by asking for the employee and the date of the job
i have then got a selection in a combo of the jobs that person performed on
that day. they will then select the approriate one. this gives me the primary
key for the job. how do i then get my text box with the finish date in it to
put that date into this record under the finishdate field?
thanks
:
Bound combos are not a bad thing, but they can be problematic. The easiest
way to do this would be to assign the value to the text box in the After
Update event of the combo:
Me.MyTextBox = Me.MyCombo
:
I have a form which by a series of cascading combos get the user to select an
old record. I now want to enter something into one of that record's fields
using a text box. How do I tell that text box to add the data to the record
found in the combo above?
many thanks,
James