COMMAND BUTTON OPEN FORM

V

Vic

I have a form called Load Info. In this form I put a load number in. Then I
have to close the form and go to another form which prompts for the customer
name, city and state. That form also has a sub form attached to it and in
that sub form I put in the load number.

After completing this process I have to go back to my Load Info for and fill
in the rest of the information I need. This form has tabs and in one of the
tabs it now displays the customers for this load after I had entered in the
load number in the customer form/sub form.

This all works great but then I got a crazy idea. Why not just do a command
button and open up the customer form. This works great. It still asks me
for the customer name, city and state. If the customer is in the database
all the data is displayed.

Now comes two problems with this brilliant idea. I go to put a load number
on the sub form of the customer form and it tells me I can’t. I tried
editing customer information and it won’t let me. The other problem is that
if the customer doesn’t exist I don’t even get the form displayed to fill in
new customer information.

Now all this works correctly if I’m not opening the form in the Load Info
form using the command button. I thought I could eliminate some steps and
makes things easier but I see that’s not the case. I even thought this might
be related to opening the customer form in the Load Info form so I thought I
would create a macro and close the Load Info form, open the customer form and
once I close the customer form the load info form would open up again. That
resulted in the same problems I have now.

Can anyone tell me why this is happening. Everything works great if I do
things the old way. This new idea would have been a great solution in
reducing steps I have to take but it’s pretty much blown up in my face.

Anyone idea’s of what’s going on???????
 
M

Maurice

Vic,

My guess would be that the main form is still 'dirty'. Normally when you
work the old way you close the form and then the form is no longer dirty. So
what you can try is placing the following in the code behind the button you
use for opening the form:

me.dirty = false
'- rest of code goes here which is what you already have...

hth
 
V

Vic

Do I put that somewhere in here? I can't find anything on the button
properties to place that. Thx

Private Sub CustSrch_Click()
On Error GoTo Err_CustSrch_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_CustomerSearch"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CustSrch_Click:
Exit Sub

Err_CustSrch_Click:
MsgBox Err.Description
Resume Exit_CustSrch_Click

End Sub
 
M

Maurice

Yes you put it in here:

Private Sub CustSrch_Click()
On Error GoTo Err_CustSrch_Click

Dim stDocName As String
Dim stLinkCriteria As String

me.dirty=false '-> this is were it should be...

stDocName = "frm_CustomerSearch"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CustSrch_Click:
Exit Sub

Err_CustSrch_Click:
MsgBox Err.Description
Resume Exit_CustSrch_Click

End Sub

hth
 
V

Vic

That didn't work. Any suggestions. Thx

Maurice said:
Yes you put it in here:

Private Sub CustSrch_Click()
On Error GoTo Err_CustSrch_Click

Dim stDocName As String
Dim stLinkCriteria As String

me.dirty=false '-> this is were it should be...

stDocName = "frm_CustomerSearch"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CustSrch_Click:
Exit Sub

Err_CustSrch_Click:
MsgBox Err.Description
Resume Exit_CustSrch_Click

End Sub

hth
 

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