Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Invalid or Unqualified Reference (Access 2003)

    Previous code worked ok... trying to split it into a function... when i do so , i get that error message.

    <font color=red>Private Sub Command200_Click()
    Dim objWord As Word.Application
    Set objWord = New Word.Application
    Dim CurrentYear As Integer
    Dim BaliffNo As String
    Dim Baseloop As Integer
    Dim shp As Word.Shape

    Baseloop = 1

    CurrentYear = DLookup("Year", "Options")
    BaliffNo = DLookup("BaliffPhone", "Options")

    Set objWord = CreateObject("Word.Application")
    objWord.Visible = True

    With objWord

    .Documents.Open ("Cocuments and Settingse79684DesktopCliffLAS.doc")</font color=red>

    <font color=448800>Call DoLabel</font color=448800>






    <font color=blue>Function DoLabel()

    . ActiveDocument .Bookmarks("A" & Baseloop).Select
    .Selection.Text = CurrentYear
    </font color=blue>
    It errors out on the Activedocument text, in bold above.

  2. #2
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Invalid or Unqualified Reference (Access 2003)

    Steve
    Try converting baseloop in the function to a string before concatenating.
    Also, baseloop doesn't seem to be incremented - always 1 ?
    John

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Invalid or Unqualified Reference (Access 2003)

    .ActiveDocument doesn't refer to anytning within the DoLabel function. And BaseLoop isn't defined in the function either. I'd move the code into Command200_Click.

  4. #4
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Invalid or Unqualified Reference (Access 2003)

    Have done so. many thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •