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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
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
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

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
Back
Top