I will admit I'm not a VB programmer, so I need desperately need help. I'm trying to select a data record from a source table in order to copy the information into a form. I'm attempting to prompt the user to enter the unique record identifier, in this case it's the file number (named SLO) so that the SLO and the CaseName appears on the form.
I recorded a macro and attempted to edit it to do exactly what I want it to do. However, it bombs out after I enter the SLO. PLEASE HELP!!!! THANKS!
Dim varcasenumber As Integer
varcasenumber = InputBox("Enter SLO#"
(I get the error message at this point)
ActiveDocument.MailMerge.DataSource.QueryString = _
"SELECT CaseName FROM H:\Cases\Active Case Data for Word.doc WHERE SLO = '[varcasenumber]'"
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
Selection.EndKey Unit:=wdStory, Extend:=wdExtend
Selection.Fields.Locked = True
Selection.HomeKey Unit:=wdStory
ActiveDocument.Protect Password:="", NoReset:=False, Type:= _
wdAllowOnlyFormFields
End Sub
I recorded a macro and attempted to edit it to do exactly what I want it to do. However, it bombs out after I enter the SLO. PLEASE HELP!!!! THANKS!
Dim varcasenumber As Integer
varcasenumber = InputBox("Enter SLO#"
(I get the error message at this point)
ActiveDocument.MailMerge.DataSource.QueryString = _
"SELECT CaseName FROM H:\Cases\Active Case Data for Word.doc WHERE SLO = '[varcasenumber]'"
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
Selection.EndKey Unit:=wdStory, Extend:=wdExtend
Selection.Fields.Locked = True
Selection.HomeKey Unit:=wdStory
ActiveDocument.Protect Password:="", NoReset:=False, Type:= _
wdAllowOnlyFormFields
End Sub