Jack_Maloney
Registered User.
- Local time
- Today, 23:12
- Joined
- Dec 22, 2010
- Messages
- 13
Hi,
Basically, I wish to automatically select a combobox value when the form loads based on a value selected in another form.
So just to give you an overview of what my forms look like I have a form called 'View_Sales_Orders_frm' with a combo box which we'll call combo1 for now. If the user selects a value from combo 1 and then selects the 'New Sales Order Log' button it opens another form called 'New_Sales_Order_frm' with another combo box which we'll call combo2. I basically want the value in combo2 to be equal to that selected in combo1 when the form first loads.
However, I cant get the value of combo2 to automatically match that of combo1. Here is the code I have so far. I may well be on the wrong track here so would much appreciate it if someone could point out what im doing wrong!
Private Sub New_Sales_Order_Log_btn_Click()
Dim strProjectNameField As String
Dim strWhere As String
strProjectNameField = "[combo2]"
'Build the filter string
If Me.combo1.Value <> vbNullString Then
strWhere = strWhere & "(" & strProjectNameField & " = " & Me.combo1.Value & ")"
End If
'Debug.Print strWhere
DoCmd.Close acForm, "View_Sales_Orders_frm"
DoCmd.OpenForm "New_Sales_Order_frm", , strWhere
DoCmd.GoToRecord , , acNewRec
End Sub
Basically, I wish to automatically select a combobox value when the form loads based on a value selected in another form.
So just to give you an overview of what my forms look like I have a form called 'View_Sales_Orders_frm' with a combo box which we'll call combo1 for now. If the user selects a value from combo 1 and then selects the 'New Sales Order Log' button it opens another form called 'New_Sales_Order_frm' with another combo box which we'll call combo2. I basically want the value in combo2 to be equal to that selected in combo1 when the form first loads.
However, I cant get the value of combo2 to automatically match that of combo1. Here is the code I have so far. I may well be on the wrong track here so would much appreciate it if someone could point out what im doing wrong!
Private Sub New_Sales_Order_Log_btn_Click()
Dim strProjectNameField As String
Dim strWhere As String
strProjectNameField = "[combo2]"
'Build the filter string
If Me.combo1.Value <> vbNullString Then
strWhere = strWhere & "(" & strProjectNameField & " = " & Me.combo1.Value & ")"
End If
'Debug.Print strWhere
DoCmd.Close acForm, "View_Sales_Orders_frm"
DoCmd.OpenForm "New_Sales_Order_frm", , strWhere
DoCmd.GoToRecord , , acNewRec
End Sub