T
Thronz
I have a database (obviously, if I'm writing here...) and I want to create a
word document from certain records. The form is working, except for certain
fields. I can't figure out why the VBA is allowing certain fields to be
passed but balking at others. I the coding I am having trouble with:
Private Sub Printform_Click()
On Error GoTo Err_Printform_Click
Dim wrdApp As Word.Application
Dim doc As String
Dim name As String
Dim Address1 As String
Dim allname As String
Dim Address2 As String
Dim dateobirth As String
Dim boss As String
Dim getin As String
Dim Contact1 As String
Dim locat As String
Set wrdApp = New Word.Application
doc = "N:\Security\Reception\Forms\Contractor Renewal Form.doc"
locat = "N:\Security\Reception\Contractors" & "\" & Me.ID & ".jpg"
Address1 = Me.Address & " " & Me.City
allname = Me.Given1 + " " & Me.Given2
dateobirth = Me.DOB
boss = Me.Employer
getin = Me.ReasonforAccess
MsgBox ("Good so far!!")
-------a debugging flag. This is where I get the problem. the next two
values are not passed.
Lastname = Me.Surname
MsgBox (Lastname)
Contact1 = Me.CentreContact
MsgBox (Contact1)
'name = Me.Surname '+ ", " & Me.Given1 + " " & Me.Given2
'wrdApp.Documents.Open filename:=doc
'ActiveDocument.FormFields("Name").Result = Me.Surname & ", " & Me.Given1 &
" " & Me.Given2
ActiveDocument.FormFields("Address").Result = Address1
ActiveDocument.FormFields("ID").Result = Me.ID
ActiveDocument.FormFields("DOB").Result = Me.DOB
ActiveDocument.FormFields("Employer").Result = Me.Employer
ActiveDocument.FormFields("Reason").Result = Me.ReasonforAccess
'ActiveDocument.FormFields("Contact").Result = Me.CentreContact
ActiveDocument.Bookmarks("Photo").Select
Selection.InlineShapes.AddPicture filename:=locat
wrdApp.Visible = True
MsgBox ("ready to print")
ActiveDocument.PrintOut
Set wrdApp = Nothing
Err_Printform_Click:
End Sub
What I need to know is why some fields are passed and others cause the code
to hang up.?
word document from certain records. The form is working, except for certain
fields. I can't figure out why the VBA is allowing certain fields to be
passed but balking at others. I the coding I am having trouble with:
Private Sub Printform_Click()
On Error GoTo Err_Printform_Click
Dim wrdApp As Word.Application
Dim doc As String
Dim name As String
Dim Address1 As String
Dim allname As String
Dim Address2 As String
Dim dateobirth As String
Dim boss As String
Dim getin As String
Dim Contact1 As String
Dim locat As String
Set wrdApp = New Word.Application
doc = "N:\Security\Reception\Forms\Contractor Renewal Form.doc"
locat = "N:\Security\Reception\Contractors" & "\" & Me.ID & ".jpg"
Address1 = Me.Address & " " & Me.City
allname = Me.Given1 + " " & Me.Given2
dateobirth = Me.DOB
boss = Me.Employer
getin = Me.ReasonforAccess
MsgBox ("Good so far!!")
-------a debugging flag. This is where I get the problem. the next two
values are not passed.
Lastname = Me.Surname
MsgBox (Lastname)
Contact1 = Me.CentreContact
MsgBox (Contact1)
'name = Me.Surname '+ ", " & Me.Given1 + " " & Me.Given2
'wrdApp.Documents.Open filename:=doc
'ActiveDocument.FormFields("Name").Result = Me.Surname & ", " & Me.Given1 &
" " & Me.Given2
ActiveDocument.FormFields("Address").Result = Address1
ActiveDocument.FormFields("ID").Result = Me.ID
ActiveDocument.FormFields("DOB").Result = Me.DOB
ActiveDocument.FormFields("Employer").Result = Me.Employer
ActiveDocument.FormFields("Reason").Result = Me.ReasonforAccess
'ActiveDocument.FormFields("Contact").Result = Me.CentreContact
ActiveDocument.Bookmarks("Photo").Select
Selection.InlineShapes.AddPicture filename:=locat
wrdApp.Visible = True
MsgBox ("ready to print")
ActiveDocument.PrintOut
Set wrdApp = Nothing
Err_Printform_Click:
End Sub
What I need to know is why some fields are passed and others cause the code
to hang up.?