Copy from combo box to text box

G

Guest

I have a combo box that is querying the table [vehicles] if the vin is not
found in the current form it creates a new record. The question I have is how
do I get it to paste the original vin from the combo box to the vin cell on
the form? Everyting is working but I can't get the copy and paste function to
work.

This is the code I am using now.

Private Sub Search_Vehicles_AfterUpdate()
Dim strCriteria As String

strCriteria = "[vin] = '" & Search_Vehicles & "'"

Me.RecordsetClone.FindFirst (strCriteria)
If Me.RecordsetClone.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End Sub
 
T

tony

You could do this a couple of ways

One way is to set the data source of the field = to the combox column
ie = [VINDATACOMBO].Column(1)

Another way is to use a macro and use the "setvalue" function with
conditions if necessary to get the end result. Setvalue will take the
data from one form control and put it in another control on the same or
another form.

HTH
 
G

Guest

This was my probelm. If you set the value of [vin] to equal the combobox.

Private Sub Search_Vehicles_AfterUpdate()
Dim strCriteria As String

strCriteria = "[vin] = '" & Search_Vehicles & "'"

Me.RecordsetClone.FindFirst (strCriteria)
If Me.RecordsetClone.NoMatch Then
DoCmd.GoToRecord , , acNewRec
[VIN] = Search_Vehicles //addition to complete copy data

Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End Sub
 
T

tony

run a macro to set the field(s) value in the new form based on the VIN
field in the open search form then close the search form
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top