How do I pass a value from one form to another?

S

Steve P

I have a combo box on a form whose selected value I'd like to use as a
variable to populate the criteria for a query I've written.

How do I do this???

So far, I've manually created a new label object that I've set to
"invisable" so that the text value from the combo box can be set to the
label's caption.

Upon the form loading, I want the code to check the value of its label's
caption and store that value in a variable to be used as criteria....but its
not working! I keep getting an error message saying that one of the forms
cannot be found. What am i doing wrong???

Here is the code I'm using on the command button that will store the combo
box's value and attempt to set the opening form's label caption...there must
be a better way to do this....



Private Sub cmdSelectEntity_Click()

[Forms]![frmAuditEntitySelector]![cboEntityName].[SelText] =
[Forms]![frmCommentAddEntity]![lblentitypass]![Caption]

DoCmd.Close acForm, "frmAuditEntitySelector"

DoCmd.Close acForm, "frmSwitchboard"

DoCmd.OpenForm "frmCommentAddEntity", acNormal, "", "", , acNormal


End Sub
 
S

Steve

The form the combobox is on must be open. Use:
Forms!NameOfComboBoxForm!NameOfCombobox

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top