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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Data to Word using VBA

Status
Not open for further replies.

JCDarr1327

Technical User
Sep 7, 2010
2
US
I am trying to use a word template that will populate data (customer info) based on based on a unique customer number entered in a field. The data source is a linked Access Database

I have tried 2 ways, I used the mail merge option which populates a form based on a record #, not the customer. I looked into writing VBA with the mail merge but it seemed complicated and there is very little literature on doing this.

I then set up the fields needed to be populated with text boxes and tried running Dlookup with VBA but I hit another wall with the 424 Runtime error.

Can anyone see what I am doing wrong?

TextBox13 value will be text 'Smith Plumbing'
TextBox1 one is number 12345
Cust_name is the column in access i want to bring back
CreditAppCustData is the table name
Cust_Num is the refernece field

Private Sub TextBox13_Change()

TextBox13.Value = Access.Application.Dlookup("'Cust_Name'", "CreditAppCustData", "Cust_Num=" & TextBox1.Value & " ")

End Sub

Please help!

Jason
 
I'd use a Recordset instead of an uninstantiated Access.Application

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Isn't Recordset an Access function? So wouldn't I still have to declair the function?
 
Isn't Recordset an Access function?
No, it's a DAO (or ADODB) object.
Add a reference to the Microsoft DAO 3.x Object Library.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top