Help!!! Click event not working as expected.

A

Ayo

This code is not working properly. What do you think is wrong?

Private Sub cmdChangeVendor1_Click()
DoCmd.Close acForm, "Invoice by Market Reviewer", acSaveYes
DoCmd.OpenForm "Selections", acNormal
End Sub

The issue is, I have a form,form1, that has txtbox1, a subform and a
cmdbutton1. And I have another form, form2, that has a cmbbox2 and a
cmdbutton2.
What I want to do is click the cmdbutton2 and open form1 with txtbox filled
out with the value of cmbbox2.
When I click on cmdbutton2 I want to return to form1 hence,the above code
snippet. But What happens is when I click on cmdbutton2, if txtbox1 has a
value in it, the code doesn't. But if txtbox1 is empty the code works fine.
My question is, do I have to clear form2 when I close it for this to work as
expected or is there something else I need to do?

Please help.
Ayo
 
J

John W. Vinson

This code is not working properly. What do you think is wrong?

Private Sub cmdChangeVendor1_Click()
DoCmd.Close acForm, "Invoice by Market Reviewer", acSaveYes
DoCmd.OpenForm "Selections", acNormal
End Sub

The issue is, I have a form,form1, that has txtbox1, a subform and a
cmdbutton1. And I have another form, form2, that has a cmbbox2 and a
cmdbutton2.
What I want to do is click the cmdbutton2 and open form1 with txtbox filled
out with the value of cmbbox2.
When I click on cmdbutton2 I want to return to form1 hence,the above code
snippet. But What happens is when I click on cmdbutton2, if txtbox1 has a
value in it, the code doesn't. But if txtbox1 is empty the code works fine.
My question is, do I have to clear form2 when I close it for this to work as
expected or is there something else I need to do?

Please help.
Ayo

You may be making a (very reasonable!) incorrect assumption about the function
of acSaveYes. It does NOT save the data in the form to the table - it saves
any *design changes* to the form.

YOu're not doing anything in this code to put a value anywhere, though. What
are the Control Sources of cmbbox2 and txtbox?


John W. Vinson [MVP]
 
J

John W. Vinson

Control Sources of cmbbox2 and txtbox are from Queries.

So?

If they are from queries, or they are from tables, it does me no good to know
that, if you don't tell me WHAT tables or queries. Are they referring to the
same field in a table? If so, you may need to Requery the textbox in addition
to closing the form.

John W. Vinson [MVP]
 
A

Ayo

The cmbbox is the only control link to the query. The cmbbox form passes that
value to the textbox in the 2nd form. The value of the textbox, in the 2nd
form, is then used to generate data in the subform, also on the 2nd form.
If there is no value in the txtbox, the button works fine. But when the
txtbox has a value in it, instead of the form closing and another form
opening, like it is surpose to do, it just close the form without opening the
other form.

Private Sub cmdChangeVendor1_Click()
DoCmd.Close acForm, "Invoice by Market Reviewer", acSaveYes
DoCmd.OpenForm "Selections", acNormal
End Sub
 

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