Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Form and add New Record

Status
Not open for further replies.

MAPetry

Technical User
Aug 2, 2000
43
0
0
US
I have a main form from which I want to open another form and add a new record with the compnay of the new record equal to the company of the original form. Being VB challenged I am not getting this to work. Following is code I currently have. ANy help would be appreciated.

** Also can anyone recommend a good starter VB book for access.

Thanks,
Mary Ann

Private Sub Create_Fax_Click()
On Error GoTo Err_Create_Fax_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Fax"
stLinkCriteria = "Forms![Fax]![FaxCompany]=" & Me![ID]
DoCmd.OpenForm stDocName, , , , acFormAdd, stLinkCriteria

Exit_Create_Fax_Click:
Exit Sub

Err_Create_Fax_Click:
MsgBox Err.Description
Resume Exit_Create_Fax_Click

End Sub
 
Your code is mostly correct, the only problem I see is in the stlinkcriteria statement. The Criteria needs to refer to the table/query that is the Fax form's recordsource.

For example if the field in your table/query is called FaxId then the statement would be:

stLinkCriteria = "[FaxId] = " & me!ID


Sorry, I don't have any book recommendations. I sorta learned by doing. Maq B-)
<insert witty signature here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top