A Strange Problem

notoca

New Member
Joined
Sep 8, 2003
Messages
37
I have a table called Invoice Details and another called Customer Details. In the form for Invoice Details I have a combo box that reads the customer's name from the Customer Details Table. If the customer name doesn't exist I have an "Add New Customer" button. When it is clicked the Customer Details form is opened (and the Invoice Details form is hidden) to allow the user to add in a new customer. When the Customer Details form is closed the Invoice Details form reappears. Clicking on the combo box will now reveal the new customer as part of the drop down list and the user can carry on completing the Invoice form. A great tool.

However, if you want to edit the customer details form directly, it opens up the Invoice details form as well. I need to find a way to stop this from happening - ie only when the customer details form is opened directly (not from within the Invoice details form using the Add New Customer button.

The code is here as others may find it useful as well:

Private Sub Add_New_Customer_Click()
On Error GoTo Err_Add_New_Customer_Click

Dim stDocName As String
Dim stLinkCriteria As String

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

Exit_Add_New_Customer_Click:
Exit Sub

Err_Add_New_Customer_Click:
MsgBox Err.Description
Resume Exit_Add_New_Customer_Click
Me.Refresh
End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
Check the OnOpen, OnLoad and OnCurrent events for the Custmers form to see whether they reference Invoices and cause it to open. If so, remove this code.

Denis
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,322
Messages
5,769,451
Members
425,548
Latest member
macjagger17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top