command button to open another form...

DeanRowe

Registered User.
Local time
Today, 18:15
Joined
Jan 26, 2007
Messages
142
Hi,
I'm using Access 2000.

I currently use two forms, one to enter my [customers] info, then other to enter the [products] they want to buy.

Once I've entered the customers details, I want to be able to press a button and it open up a new record in the [products] and already show the customers unique ID.

I've followed the wizard and it does open up the [products] form, and it does bring the unique ID, but it doesn't start a new record, it overwrites the existing data!

Here's the code I'm currently using, can anyone see what I'm doing wrong please? or know of any tutorials that could help me? I've ordered an Access Bible but it won't arrive for a few days.

Private Sub new_request_Click()
On Error GoTo Err_new_request_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ProductsEntryForm"

stLinkCriteria = "[Performed for Customer]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_new_request_Click:
Exit Sub

Err_new_request_Click:
MsgBox Err.Description
Resume Exit_new_request_Click

End Sub



Any help would be greatly appreciated!

Many thanks,

Dean
 
The simplest thing would be to change the Data Entry property on the form being opened to Yes, if it's only used for entering new records, as its name implies.
 
thanks pbaldy,

sorry, i dont quite know how to do this?
 
Open the form in design view. Go into it's properties. On the data tab is one called "Data Entry". Set it to Yes. Save and test.
 

Users who are viewing this thread

Back
Top Bottom