Passing Newly-Created AutoNumber Index to Form

DJ7T

Registered User.
Local time
Today, 11:30
Joined
Dec 5, 2001
Messages
11
I'm just going to ask because I'm so confused I don't know where to start.

I have a fairly boring, standard RDBM set up - I have a "customers" table, with an AutoNumber "customer index" field, and I need to do transactions per customer (actually, I'm tracking service & repair in a computer repair shop), that is, we start a ticket for a customer and track a repair.

When the user clicks into the Service & Repair portion from the switchboard, they get the option to start a new ticket. Picking this option brings up a dialog with a list of customers already entered into the system. At this point I need to know how to do two things:

1. If the customer exists, I want them to double-click on the customer's name and have Access open the main Service tracking form, opening a new record and inserting that "customer index" AutoNumber into the new record. I know how to read the AutoNumber from the selection form when the user double-clicks, but I don't know how to pass it to the main form, or how to tell the main form to expect it.

2. I want an option on the pick-your-customer form to add a *new* customer, currently not in the database. I know how to make an "add user" form pop up, but when they click "OK" to add that user, I then want the Main form to appear with that user's info in it (remember, my Main form only holds the "user index" AutoNumber). Far as I can tell, I need to first save the record in the "add user" form, then figure out a way to pull the AutoNumber out that it *just* added in that record, then pass it to the main form. And I can't figure out how to do that.

Any help is desperately appreciated :-).

-Mark
 
Assuming you know the Customer ID number you can easily pass it by creating a global variable in a code module. Open a new module and enter ...
Public gCustomerID as Long
... right after the last of the general declarations.

Add a value to this variable in the double click event of the customer list.

gCustomerID = Me.lstCustomers

IN order to get the customer id into your new record, add something like this to your FormCurrent event ...

If Me.NewRecord = True then
If gCustomerID > 0 Then
me.cboCustomer = gCustomerID
end if
end if
This assumes that you have a Combo box on the Service Tracking form that holds customer id in column 1 and customer name in column 2.

If you have entered a new customer in a third form, you should be able to pass the new customer id to the global variable in the AfterInsert of the Customer form. You would then have the option of going straight to the Service and Repair form or back to the dialog form. No reason to do the latter as far as I can see.
HTH
Chris
 

Users who are viewing this thread

Back
Top Bottom