Results 1 to 4 of 4
  1. #1
    PrintShopSup is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2010
    Posts
    11

    Using Dlookup in unbound text box in report

    I have searched some time to be able to pull a value not in my report table to my report. I found that I was able to use the DLookup function to get that variable upon opening my report. My issue is when I try to assign that variable to an unbound text box in the report. I get a run-time error. The run time error is shown below along with the code. Any advice would be greatly appreciated.



    Run-time error '-2147352567 (800200009)':

    You can't assign a value to this object.
    Code:
    Private Sub Report_Open(Cancel As Integer)
    Dim stLocation As String
    stLocation = DLookup("[fldLocationName]", "[qryLocationByUser]")
    'check to verify correct data
    MsgBox stLocation, vbOKOnly, "My Location"
    Me.txtLocationbx = stLocation
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Use the Format or Print event of the detail section to assign the variable to a control. The Open event is too early in the process.

  3. #3
    PrintShopSup is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2010
    Posts
    11
    I was able to assign the code to the On Activate Event and achieve my expected results. Thanks for the prompt response and to point me in the right direction.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad you got it sorted.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Input data In unbound text box
    By chu3w in forum Forms
    Replies: 1
    Last Post: 04-01-2010, 10:21 AM
  2. Unbound Text box in reports
    By Overdive in forum Reports
    Replies: 1
    Last Post: 02-17-2010, 09:52 AM
  3. Bound a unbound text box to the table
    By Brian62 in forum Forms
    Replies: 1
    Last Post: 11-06-2009, 11:05 AM
  4. Transfer Text to Unbound Form
    By DWS in forum Forms
    Replies: 3
    Last Post: 08-25-2009, 08:04 AM
  5. Unbound text box truncating text
    By gddrew in forum Forms
    Replies: 0
    Last Post: 03-02-2006, 11:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums