Results 1 to 3 of 3

Thread: change Access recordset with code

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Cool

    I need to change one of two things with code in a formula in MSAccess 2000 - either the SQL of a Query or the RecordSource of a Report. Unfortunately I can not figure out how to reference the query in code, and when I try to change the RecordSource of the Report, I get the error that I cannot reference or set a value of an object that does not have the focus.

    Any hints would be greatly appreciated.

    Thank you

    Andrew

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What EXACTLY are you trying to do? To change the recordset for a report put something like this in the Report_Open event of the report or if you are subclassing just include events and then do it.

    Me.Recordsource="SELECT * FROM [My Table]"

    That is something simple, it depends what you are trying.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    That is the basic idea. I have the report's datasource set to a query to begin with, and in a field "LastName" in the query I have the filter criteria

    Like[Enter the beginning of the last name:] & "*"

    so that when the user opens the query a window appears that prompts them to enter the first letters of the last name. At another place in the program I need to be able to directly pass the LastName parameter without prompting the user for input. I can change the recordsource in the ReportOpen routine like you said, but the window still appears prompting the user for input.

Posting Permissions

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



Click Here to Expand Forum to Full Width