Results 1 to 6 of 6
  1. #1
    Cheshire101 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    42

    Question Resetting Record Source on Form

    Ok I am probably missing something obvious so any help would be appreciated....
    The original record source for a form is as follows:


    Code:
    SELECT tblTablename.*, DCount("Field1","tblTable2","Field1='" & [Field2] & "'") AS UseCount FROM tblTableName;

    The user can run a filter to change data on the form which works fine until I try and reset the record source to the above information:
    I know the problem is with the “quotes”, but I cannot remember how to work around that.
    I want to end up something like:
    Code:
    Form_MYFORM.RecordSource = “SELECT tblTablename.*, DCount("Field1","tblTable2","Field1='" & [Field2] & "'") AS UseCount FROM tblTableName;”

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you changing the RecordSource to something different or do you just want to Requery the original RecordSource?

  3. #3
    Cheshire101 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    42
    Quote Originally Posted by RuralGuy View Post
    Are you changing the RecordSource to something different or do you just want to Requery the original RecordSource?
    I am trying to change the record source

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm going to suggest a technique to achieve the results you want. Create the string as several parts that can be tested with a MsgBox or Debug.Print statements. The easiest way is to use the Chr(34) where you need a quote on the string. You could also use double sets of quotes ("") which will leave one in the string.

  5. #5
    Cheshire101 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    42
    Thank you..worked like a charm.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Glad we could help.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-29-2010, 11:16 AM
  2. change print preview record source
    By alaric01 in forum Reports
    Replies: 10
    Last Post: 10-07-2010, 09:51 AM
  3. Replies: 1
    Last Post: 07-04-2010, 03:31 PM
  4. Forms' Record Source
    By Progress2007 in forum Programming
    Replies: 11
    Last Post: 07-27-2009, 11:04 AM
  5. Changing the record source in a form
    By lmichaud in forum Forms
    Replies: 1
    Last Post: 07-09-2006, 09:20 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