Open Form – Default item in combo box

ardy

Registered User.
Local time
Yesterday, 20:40
Joined
Sep 24, 2012
Messages
98
Hello All.
I am using the same form (form_x) to add new assignments and new tests. The form (form-x) gets invoked with two buttons (New Assignment – New Exam). In the form (form-x) I have a combo box by which I identify if the record is type Exam or Assignment. I am using the following code to invoke the form.
Code:
  Private Sub btn_AddTest_Click()
  ' open Add test-Assignment Add form
      DoCmd.OpenForm "frm_TA_Add_Global"
  End Sub
Is there a way to make the form (form-x) once opens to have the default of either Exam or Assignment in The combo box.

Ardy
 
Use the "Default value" property tor the combobox.
 
Thanks for the reply, but maybe I am not explaining this correctly......
let me try again......
we have form(A) on this form there are two buttons (create test, Create Assignment). the two button are pointing to the same form(B).(yes I know ...Why two button are pointing to the same thing, but for now lets not pay attention to that) on form (B), which is create test or assignment form, there is a combo box that the user needs to identify if the record is test or assignment(controlled vocabulary). now my goal is

A - if the user pushes the test button from Form(A) and form (B) opens the combo box automatically back fill with the word "Exam".
B - if the user pushes the Assignment button from form(A) and Form(B) opens the combo box automatically back fill with the word "Assignment"

the default works but it will back fill wiht one of the two.......

Ardy
 
You could have the value of the box be filled in by the code in your buttons. So the button code would be like:

Code:
 Private Sub btn_AddTest_Click()
  ' open Add test-Assignment Add form
      DoCmd.OpenForm "frm_TA_Add_Global"
      Forms![frm_TA_Add_Global]![YourComboBoxNameHere] = "Exam"
  End Sub

Then you could make the other button the same but with "Assignment" as the thing it is writing into the box. Hopefully I have understood your correctly!
 
Then use the OpenArgs to put in the value directly in the combobox (or set the default value). Do it on the form's On Load event.
Code:
  DoCmd.OpenForm "YourFormName", , , , , , "Exam"
and for the other button 
  DoCmd.OpenForm "YourFormName", , , , , , "Assignment"
And thy code on the On Load event:
Code:
Private Sub Form_Load()
  Me.YourComboboxName = Me.OpenArgs
End Sub
 
:)I love this forum, Thanks JHB and Old Man Devin, Both solutions works good. I am learning a lot, Always wondered what the OpenArgs are used for now I get it, I am sure I will be using this alot.............

Thanks
Ardy
 

Users who are viewing this thread

Back
Top Bottom