copy data from combo box to text box (2 forms)

Jaymin

Registered User.
Local time
Tomorrow, 07:46
Joined
Oct 24, 2011
Messages
70
I have a form with a combo box i select the data item from the drop down, then want to send this to another form that will populate a txt box, I can do this by using command button and a txt box on the first form, but when i use the command button with the combo box, the second form txt box dose not get populated.
Peter :mad:
 
Can you show us the code that works for the text box and the code that doesn't work for the combo box.
 
Code:
Private Sub TransferData_Click()

 If Not IsNull(Me.ComboboxName) Then

   Forms("YourSecondFormName")("SecondFormControl") = Me.ComboboxName

 Else
 
   MsgBox "There is No Data To Transfer!"

 End If

End Sub
This checks that a selection has been made from the Combobox, but if it's possible that the second Form might not be open, you need to also check for this.

Linq ;0)>
 
missinglinq,
Thank you for you reply and sample code.
the to codes are,

start of text box -------------,
Private Sub Command7_Click()
On Error GoTo Err_Command7_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmStation"

stLinkCriteria = "[StationName]=" & "'" & Me![Text0] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command7_Click:
Exit Sub
Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click

End Sub
end of text box------------

Start combo box----------
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmStation"

stLinkCriteria = "[StationName]=" & "'" & Me![Combo2] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command6_Click:
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub

combo box----------

when i press the command buttom for the text box the form that opens, the there is a text box on that form and the text box is populated with the selected selected data from the first form,

But when i do the same with the combo box the form opens but there the text box is not populated with any data.


both buttons are linked to the same form and text box.
I will have a play with the code you sent me to see if it helps me

Peter
 
Hi Peter

Try this:

Replace:
Code:
stLinkCriteria = "[StationName]=" & "'" & Me![Combo2] & "'"
With:
Code:
stLinkCriteria = "[StationName]=" & "'" & Me![Combo2][B].Column(1)[/B] & "'"
 
bob fitz,

Thank you for your help, It now works fine, many many thanks
Peter
 

Users who are viewing this thread

Back
Top Bottom