If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
HELP: Error! No document variable supplied
Hi All,
I have created a button in access form that exports certain details from the form to a word template. But when exporting textfields that has no values (on access form) displays an error: Error! No document variable supplied. Here is my code to resolve this issue but it's not working. With doc ..variables("Name").Value = Nz((Name.Value), "") ..variables("Address").Value = Nz(Address.Value, "") ..variables("City").Value = !Nz(Me.City.Value, "") ..Fields.Update End With Thanks in advance |
#2
|
|||
|
|||
Error! No document variable supplied
How are you instantiating doc? (in other words, what's the rest of the code
in the Click event?) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi All, I have created a button in access form that exports certain details from the form to a word template. But when exporting textfields that has no values (on access form) displays an error: Error! No document variable supplied. Here is my code to resolve this issue but it's not working. With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With Thanks in advance |
#3
|
|||
|
|||
Error! No document variable supplied
Hi Douglas, Thanks for helping.
Here is my whole code for the click event Private Sub Export_Click() Dim wdApp As Object Dim doc As Object Dim fdialog As FileDialog Dim pathAndFile As String Dim filePath As String Dim shortName As String filePath = "C:My Documents\Students_Info_Template.dotx" Set wdApp = CreateObject("Word.Application") Dim FName As String Set fdialog = wdApp.FileDialog(msoFileDialogFilePicker) With fdialog .AllowMultiSelect = False .Filters.Clear .InitialFileName = filePath & "\*.dotx*" If .Show Then pathAndFile = .SelectedItems(1) 'following is filename without path if required shortName = Right(pathAndFile, _ Len(pathAndFile) - InStrRev(pathAndFile, "\")) Else MsgBox "User cancelled. Did not select a file" GoTo Pastcode End If End With Set fdialog = Nothing Set doc = wdApp.Documents.Open(pathAndFile) On Error Resume Next With doc ..variables("Name").Value = Nz((Name.Value), "") ..variables("Address").Value = Nz(Address.Value, "") ..variables("City").Value = !Nz(Me.City.Value, "") ..Fields.Update End With FName = "C:My Documents\" _ & "Student_Info" & " - " & Me.Student_ID.Value & ".doc" doc.SaveAs FileName:=FName Pastcode: On Error Resume Next wdApp.Quit Set doc = Nothing Set wdApp = Nothing End Sub "Douglas J. Steele" wrote: How are you instantiating doc? (in other words, what's the rest of the code in the Click event?) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi All, I have created a button in access form that exports certain details from the form to a word template. But when exporting textfields that has no values (on access form) displays an error: Error! No document variable supplied. Here is my code to resolve this issue but it's not working. With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With Thanks in advance . |
#4
|
|||
|
|||
Error! No document variable supplied
See whether passing a space (" ") rather than a zero-length string ("") in
your Nz statement makes a difference. Incidentally, the exclamation point in the following is unnecessary: ..variables("City").Value = !Nz(Me.City.Value, "") (I suspect the only it works is that the Nz function exists in Word as well, and you're using the Word version rather than the Access version in that line) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi Douglas, Thanks for helping. Here is my whole code for the click event Private Sub Export_Click() Dim wdApp As Object Dim doc As Object Dim fdialog As FileDialog Dim pathAndFile As String Dim filePath As String Dim shortName As String filePath = "C:My Documents\Students_Info_Template.dotx" Set wdApp = CreateObject("Word.Application") Dim FName As String Set fdialog = wdApp.FileDialog(msoFileDialogFilePicker) With fdialog .AllowMultiSelect = False .Filters.Clear .InitialFileName = filePath & "\*.dotx*" If .Show Then pathAndFile = .SelectedItems(1) 'following is filename without path if required shortName = Right(pathAndFile, _ Len(pathAndFile) - InStrRev(pathAndFile, "\")) Else MsgBox "User cancelled. Did not select a file" GoTo Pastcode End If End With Set fdialog = Nothing Set doc = wdApp.Documents.Open(pathAndFile) On Error Resume Next With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With FName = "C:My Documents\" _ & "Student_Info" & " - " & Me.Student_ID.Value & ".doc" doc.SaveAs FileName:=FName Pastcode: On Error Resume Next wdApp.Quit Set doc = Nothing Set wdApp = Nothing End Sub "Douglas J. Steele" wrote: How are you instantiating doc? (in other words, what's the rest of the code in the Click event?) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi All, I have created a button in access form that exports certain details from the form to a word template. But when exporting textfields that has no values (on access form) displays an error: Error! No document variable supplied. Here is my code to resolve this issue but it's not working. With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With Thanks in advance . |
#5
|
|||
|
|||
Error! No document variable supplied
Hey Douglas,
Keeping a space worked instead of a null Thanks! "Douglas J. Steele" wrote: See whether passing a space (" ") rather than a zero-length string ("") in your Nz statement makes a difference. Incidentally, the exclamation point in the following is unnecessary: ..variables("City").Value = !Nz(Me.City.Value, "") (I suspect the only it works is that the Nz function exists in Word as well, and you're using the Word version rather than the Access version in that line) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi Douglas, Thanks for helping. Here is my whole code for the click event Private Sub Export_Click() Dim wdApp As Object Dim doc As Object Dim fdialog As FileDialog Dim pathAndFile As String Dim filePath As String Dim shortName As String filePath = "C:My Documents\Students_Info_Template.dotx" Set wdApp = CreateObject("Word.Application") Dim FName As String Set fdialog = wdApp.FileDialog(msoFileDialogFilePicker) With fdialog .AllowMultiSelect = False .Filters.Clear .InitialFileName = filePath & "\*.dotx*" If .Show Then pathAndFile = .SelectedItems(1) 'following is filename without path if required shortName = Right(pathAndFile, _ Len(pathAndFile) - InStrRev(pathAndFile, "\")) Else MsgBox "User cancelled. Did not select a file" GoTo Pastcode End If End With Set fdialog = Nothing Set doc = wdApp.Documents.Open(pathAndFile) On Error Resume Next With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With FName = "C:My Documents\" _ & "Student_Info" & " - " & Me.Student_ID.Value & ".doc" doc.SaveAs FileName:=FName Pastcode: On Error Resume Next wdApp.Quit Set doc = Nothing Set wdApp = Nothing End Sub "Douglas J. Steele" wrote: How are you instantiating doc? (in other words, what's the rest of the code in the Click event?) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi All, I have created a button in access form that exports certain details from the form to a word template. But when exporting textfields that has no values (on access form) displays an error: Error! No document variable supplied. Here is my code to resolve this issue but it's not working. With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With Thanks in advance . . |
#6
|
|||
|
|||
Error! No document variable supplied
Hey Douglas,
I am having an issue when I export fields that are hyperlinked in access to export or to word. I get an extra string attached to the actual value, something like "124 South West St#http://124 South West St#" and something like this when i hyperlink it to a pdf doc "1234 street#C:\Documents\Appr 2027 Cullom Chicago, IL.pdf#" Do you know how to resolve it? Thanks in advance "Douglas J. Steele" wrote: See whether passing a space (" ") rather than a zero-length string ("") in your Nz statement makes a difference. Incidentally, the exclamation point in the following is unnecessary: ..variables("City").Value = !Nz(Me.City.Value, "") (I suspect the only it works is that the Nz function exists in Word as well, and you're using the Word version rather than the Access version in that line) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi Douglas, Thanks for helping. Here is my whole code for the click event Private Sub Export_Click() Dim wdApp As Object Dim doc As Object Dim fdialog As FileDialog Dim pathAndFile As String Dim filePath As String Dim shortName As String filePath = "C:My Documents\Students_Info_Template.dotx" Set wdApp = CreateObject("Word.Application") Dim FName As String Set fdialog = wdApp.FileDialog(msoFileDialogFilePicker) With fdialog .AllowMultiSelect = False .Filters.Clear .InitialFileName = filePath & "\*.dotx*" If .Show Then pathAndFile = .SelectedItems(1) 'following is filename without path if required shortName = Right(pathAndFile, _ Len(pathAndFile) - InStrRev(pathAndFile, "\")) Else MsgBox "User cancelled. Did not select a file" GoTo Pastcode End If End With Set fdialog = Nothing Set doc = wdApp.Documents.Open(pathAndFile) On Error Resume Next With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With FName = "C:My Documents\" _ & "Student_Info" & " - " & Me.Student_ID.Value & ".doc" doc.SaveAs FileName:=FName Pastcode: On Error Resume Next wdApp.Quit Set doc = Nothing Set wdApp = Nothing End Sub "Douglas J. Steele" wrote: How are you instantiating doc? (in other words, what's the rest of the code in the Click event?) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi All, I have created a button in access form that exports certain details from the form to a word template. But when exporting textfields that has no values (on access form) displays an error: Error! No document variable supplied. Here is my code to resolve this issue but it's not working. With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With Thanks in advance . . |
#7
|
|||
|
|||
Error! No document variable supplied
The reason you're getting that is because that's what's actually stored for
hyperlinks. Take a look at the HyperlinkPart function in the Help file, and use it in your query. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "sam" wrote in message ... Hey Douglas, I am having an issue when I export fields that are hyperlinked in access to export or to word. I get an extra string attached to the actual value, something like "124 South West St#http://124 South West St#" and something like this when i hyperlink it to a pdf doc "1234 street#C:\Documents\Appr 2027 Cullom Chicago, IL.pdf#" Do you know how to resolve it? Thanks in advance "Douglas J. Steele" wrote: See whether passing a space (" ") rather than a zero-length string ("") in your Nz statement makes a difference. Incidentally, the exclamation point in the following is unnecessary: ..variables("City").Value = !Nz(Me.City.Value, "") (I suspect the only it works is that the Nz function exists in Word as well, and you're using the Word version rather than the Access version in that line) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi Douglas, Thanks for helping. Here is my whole code for the click event Private Sub Export_Click() Dim wdApp As Object Dim doc As Object Dim fdialog As FileDialog Dim pathAndFile As String Dim filePath As String Dim shortName As String filePath = "C:My Documents\Students_Info_Template.dotx" Set wdApp = CreateObject("Word.Application") Dim FName As String Set fdialog = wdApp.FileDialog(msoFileDialogFilePicker) With fdialog .AllowMultiSelect = False .Filters.Clear .InitialFileName = filePath & "\*.dotx*" If .Show Then pathAndFile = .SelectedItems(1) 'following is filename without path if required shortName = Right(pathAndFile, _ Len(pathAndFile) - InStrRev(pathAndFile, "\")) Else MsgBox "User cancelled. Did not select a file" GoTo Pastcode End If End With Set fdialog = Nothing Set doc = wdApp.Documents.Open(pathAndFile) On Error Resume Next With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With FName = "C:My Documents\" _ & "Student_Info" & " - " & Me.Student_ID.Value & ".doc" doc.SaveAs FileName:=FName Pastcode: On Error Resume Next wdApp.Quit Set doc = Nothing Set wdApp = Nothing End Sub "Douglas J. Steele" wrote: How are you instantiating doc? (in other words, what's the rest of the code in the Click event?) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi All, I have created a button in access form that exports certain details from the form to a word template. But when exporting textfields that has no values (on access form) displays an error: Error! No document variable supplied. Here is my code to resolve this issue but it's not working. With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With Thanks in advance . . |
#8
|
|||
|
|||
Error! No document variable supplied
Hey Douglas, The HyperlinkPark function worked out great! Thanks!!
I wanted to auto backup my access database every night at a certain time.. Can that be done? Thanks in advance "Douglas J. Steele" wrote: The reason you're getting that is because that's what's actually stored for hyperlinks. Take a look at the HyperlinkPart function in the Help file, and use it in your query. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "sam" wrote in message ... Hey Douglas, I am having an issue when I export fields that are hyperlinked in access to export or to word. I get an extra string attached to the actual value, something like "124 South West St#http://124 South West St#" and something like this when i hyperlink it to a pdf doc "1234 street#C:\Documents\Appr 2027 Cullom Chicago, IL.pdf#" Do you know how to resolve it? Thanks in advance "Douglas J. Steele" wrote: See whether passing a space (" ") rather than a zero-length string ("") in your Nz statement makes a difference. Incidentally, the exclamation point in the following is unnecessary: ..variables("City").Value = !Nz(Me.City.Value, "") (I suspect the only it works is that the Nz function exists in Word as well, and you're using the Word version rather than the Access version in that line) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi Douglas, Thanks for helping. Here is my whole code for the click event Private Sub Export_Click() Dim wdApp As Object Dim doc As Object Dim fdialog As FileDialog Dim pathAndFile As String Dim filePath As String Dim shortName As String filePath = "C:My Documents\Students_Info_Template.dotx" Set wdApp = CreateObject("Word.Application") Dim FName As String Set fdialog = wdApp.FileDialog(msoFileDialogFilePicker) With fdialog .AllowMultiSelect = False .Filters.Clear .InitialFileName = filePath & "\*.dotx*" If .Show Then pathAndFile = .SelectedItems(1) 'following is filename without path if required shortName = Right(pathAndFile, _ Len(pathAndFile) - InStrRev(pathAndFile, "\")) Else MsgBox "User cancelled. Did not select a file" GoTo Pastcode End If End With Set fdialog = Nothing Set doc = wdApp.Documents.Open(pathAndFile) On Error Resume Next With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With FName = "C:My Documents\" _ & "Student_Info" & " - " & Me.Student_ID.Value & ".doc" doc.SaveAs FileName:=FName Pastcode: On Error Resume Next wdApp.Quit Set doc = Nothing Set wdApp = Nothing End Sub "Douglas J. Steele" wrote: How are you instantiating doc? (in other words, what's the rest of the code in the Click event?) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi All, I have created a button in access form that exports certain details from the form to a word template. But when exporting textfields that has no values (on access form) displays an error: Error! No document variable supplied. Here is my code to resolve this issue but it's not working. With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With Thanks in advance . . . |
#9
|
|||
|
|||
Error! No document variable supplied
Most backup software can be set up to work on a schedule. (In other words,
you're not going to back up from within Access, but from outside. Make sure that the database isn't in use when it's backed up. If you don't do that, your backup may be in an inconsistent state) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "sam" wrote in message ... Hey Douglas, The HyperlinkPark function worked out great! Thanks!! I wanted to auto backup my access database every night at a certain time.. Can that be done? Thanks in advance "Douglas J. Steele" wrote: The reason you're getting that is because that's what's actually stored for hyperlinks. Take a look at the HyperlinkPart function in the Help file, and use it in your query. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "sam" wrote in message ... Hey Douglas, I am having an issue when I export fields that are hyperlinked in access to export or to word. I get an extra string attached to the actual value, something like "124 South West St#http://124 South West St#" and something like this when i hyperlink it to a pdf doc "1234 street#C:\Documents\Appr 2027 Cullom Chicago, IL.pdf#" Do you know how to resolve it? Thanks in advance "Douglas J. Steele" wrote: See whether passing a space (" ") rather than a zero-length string ("") in your Nz statement makes a difference. Incidentally, the exclamation point in the following is unnecessary: ..variables("City").Value = !Nz(Me.City.Value, "") (I suspect the only it works is that the Nz function exists in Word as well, and you're using the Word version rather than the Access version in that line) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi Douglas, Thanks for helping. Here is my whole code for the click event Private Sub Export_Click() Dim wdApp As Object Dim doc As Object Dim fdialog As FileDialog Dim pathAndFile As String Dim filePath As String Dim shortName As String filePath = "C:My Documents\Students_Info_Template.dotx" Set wdApp = CreateObject("Word.Application") Dim FName As String Set fdialog = wdApp.FileDialog(msoFileDialogFilePicker) With fdialog .AllowMultiSelect = False .Filters.Clear .InitialFileName = filePath & "\*.dotx*" If .Show Then pathAndFile = .SelectedItems(1) 'following is filename without path if required shortName = Right(pathAndFile, _ Len(pathAndFile) - InStrRev(pathAndFile, "\")) Else MsgBox "User cancelled. Did not select a file" GoTo Pastcode End If End With Set fdialog = Nothing Set doc = wdApp.Documents.Open(pathAndFile) On Error Resume Next With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With FName = "C:My Documents\" _ & "Student_Info" & " - " & Me.Student_ID.Value & ".doc" doc.SaveAs FileName:=FName Pastcode: On Error Resume Next wdApp.Quit Set doc = Nothing Set wdApp = Nothing End Sub "Douglas J. Steele" wrote: How are you instantiating doc? (in other words, what's the rest of the code in the Click event?) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "sam" wrote in message ... Hi All, I have created a button in access form that exports certain details from the form to a word template. But when exporting textfields that has no values (on access form) displays an error: Error! No document variable supplied. Here is my code to resolve this issue but it's not working. With doc .variables("Name").Value = Nz((Name.Value), "") .variables("Address").Value = Nz(Address.Value, "") .variables("City").Value = !Nz(Me.City.Value, "") .Fields.Update End With Thanks in advance . . . |
Thread Tools | |
Display Modes | |
|
|