kate_y
asked on
how to pass value between two forms using VBA in Access 2003?
Hi, this is what i am trying to do.
I have a combo box in form1 and a button. User select a value from the combo box and click then click the button. it opens another form which does quey using the value that user selected from the combo box.
this is the query code in the form2. i want x = form1's combo box value. please help.
Dim x As String
x = form1's combo box value
Set db = CurrentDb
strSQL = "SELECT id, name FROM T_test where name = x"
Set rst = db.OpenRecordset(strSQL)
Set Me.Recordset = rst
Me.txtName.ControlSource = "Name"
Me.id.ControlSource = "id"
I have a combo box in form1 and a button. User select a value from the combo box and click then click the button. it opens another form which does quey using the value that user selected from the combo box.
this is the query code in the form2. i want x = form1's combo box value. please help.
Dim x As String
x = form1's combo box value
Set db = CurrentDb
strSQL = "SELECT id, name FROM T_test where name = x"
Set rst = db.OpenRecordset(strSQL)
Set Me.Recordset = rst
Me.txtName.ControlSource = "Name"
Me.id.ControlSource = "id"
ASKER
but when i directly use the first form name in the second form, it didn't give me the option use the .comboBox.value
thanks
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not sure but there is aproperty for combo boox called " Modifier"
change Modifier attribute to internal or public
change Modifier attribute to internal or public
and then try sa fanpages suggested
ASKER
i found a solution. thanks.
x = cboTest.Value
Form_frm_subtest.RecordSou rce = "SELECT * FROM T_test WHERE Name = '" & x & "'"
x = cboTest.Value
Form_frm_subtest.RecordSou
Thanks for closing the question.
Where Form1 is the name of "form1", and "ComboBox1" is the name of the Combo-Box control on "form1".
BFN,
fp.