Setting Combo box field

Newbie2012

Donna H
Local time
Tomorrow, 03:34
Joined
Jun 28, 2012
Messages
33
How do I go about getting data from a:

  • Text field in Form 1
  • Clicking a button to run VBA code, and
  • Automatically inserting it into a refreshed combo box in Form 2
I hope this is enough information. I've also attached a pic.

Thank you

*Also, I'm using Access 2007...
 

Attachments

  • Snapshot_16.png
    Snapshot_16.png
    39.7 KB · Views: 107
Last edited:
Make the text field record source for the field in form 2. If Form 2 opens each time you click on the button then a simple open command to open form 2 will work.

If both forms are open simultaneously then also add a requery function to update the combo box on form 2.

Hope its helpful.

Thanks,
Dad M.Hamdard
 
Look at the DoCmd openform and argument OpenArg, below is a link to a description and some sample code.
http://msdn.microsoft.com/en-us/library/office/ff836583(v=office.15).aspx

I'm not sure if this is exactly what I should do...
==========================
Sub OpenToCallahan() DoCmd.OpenForm "Employees", acNormal, , , acReadOnly, _ , "Callahan" End Sub
===============================
I'm not specifically looking for "Callahan" but any value which may be typed into the text box (on form 1)...
Would I use something like Company.Value to replace "Callahan"?
 
I've used:
================================
=[Forms]![frm Company]![Company] as the control source for the combobox for Form 2
================================

and also have this VBA code for Form 2:
================================
Private Sub CompanyID_GotFocus()
Forms![tbl Contact].Recordset.FindFirst "ID=" & Me.CompanyID
End Sub

Private Sub Company_GotFocus()
Me.Company.Requery
End Sub
=========================

...the only little issue is that Form 2 needs to be closed everytime to reset the action again for any new requests when clicking the button again...
 
No sorry it doesn't work because now I can't manually select anything from the combobox as the inserted data is just being placed there and not saved :(
 

Users who are viewing this thread

Back
Top Bottom