Connecting Tech Pros Worldwide Help | Site Map

open form with a different recordsource

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 3rd, 2008, 07:05 PM
RLN
Guest
 
Posts: n/a
Default open form with a different recordsource


RE: Access 2003

I have a SQL variable (strSQL1 dimmed as String) that gets built using
Select Case logic. The first half of strSQL1 is etched in stone no
matter what.
The 2nd half of strSQL1 (the condition) is built depending on which
option button is chosen:
For option 1, I add "Condition X" to the end of strSQL1.
For option 2, I add "Condition Y" to the end of strSQL1...etc.

When the Select Case logic is completed strSQL1 is built and I then need
to launch a form in Datasheet mode using strSQL1 as my data source.

Can this be done?


*** Sent via Developersdex http://www.developersdex.com ***

  #2  
Old July 3rd, 2008, 07:25 PM
Salad
Guest
 
Posts: n/a
Default Re: open form with a different recordsource

RLN wrote:
Quote:
RE: Access 2003
>
I have a SQL variable (strSQL1 dimmed as String) that gets built using
Select Case logic. The first half of strSQL1 is etched in stone no
matter what.
The 2nd half of strSQL1 (the condition) is built depending on which
option button is chosen:
For option 1, I add "Condition X" to the end of strSQL1.
For option 2, I add "Condition Y" to the end of strSQL1...etc.
>
When the Select Case logic is completed strSQL1 is built and I then need
to launch a form in Datasheet mode using strSQL1 as my data source.
>
Can this be done?
>
>
*** Sent via Developersdex http://www.developersdex.com ***
I suppose you could launch and change the source.
DoCmd.OpenForm "FormName", , , , , , strSQL1

Now in the OnOpen even you could do
If Not IsNull(me.openargs) then Me.Recordsource = Me.OpenArgs

But I don't see the necessity because the table info isn't
changing...just the filter. Let's say you simply make strSQL1 the
conditional then pass the filter. Ex:
strSQL1 = "customerid = 123".
DoCmd.OpenForm "FormName", , , strSQL1
and this will open it to filtered records where customerid = 123

Once in a form, you could do things like this
Me.Filter = "CustomerID = 123"
Me.FilterOn = True

Powerful
http://www.youtube.com/watch?v=YhrLBrDzj5Q
  #3  
Old July 3rd, 2008, 08:05 PM
RLN
Guest
 
Posts: n/a
Default Re: open form with a different recordsource



ok...let me add one bit of mere complexity to this if I may.

The form that calls this query is chock full of text boxes and I cannot
afford realestate on the form to put yet another generic text box for
parameter input.
Is there a way to pop an input box on the dcmd.openf rom statment so the
user can input data for this query (much like what happens when a query
is run as standalone)?

thnkx.......


*** Sent via Developersdex http://www.developersdex.com ***
  #4  
Old July 3rd, 2008, 10:05 PM
Salad
Guest
 
Posts: n/a
Default Re: open form with a different recordsource

RLN wrote:
Quote:
>
ok...let me add one bit of mere complexity to this if I may.
>
The form that calls this query is chock full of text boxes and I cannot
afford realestate on the form to put yet another generic text box for
parameter input.
Is there a way to pop an input box on the dcmd.openf rom statment so the
user can input data for this query (much like what happens when a query
is run as standalone)?
>
thnkx.......
>
That doesn't make sense. You have 2 checkboxes that determines the SQL
string for creating a filter. The recordsource of your second form
won't change, simply the criteria. Are you saying you have no command
button or use the checkbox for launching the second form? How do you
open the form?

You should be able to open a form and set the filter there if you want.

You can also open the form with the filter passed to it.

The only reason you need to change the recordsource of the second form
is if you are using other tables.





Quote:
>
*** Sent via Developersdex http://www.developersdex.com ***
  #5  
Old July 8th, 2008, 03:55 PM
RLN
Guest
 
Posts: n/a
Default Re: open form with a different recordsource

Quote:
Quote:
>>You can also open the form with the filter passed to it.
<<

You mean passed in as a parm?


*** Sent via Developersdex http://www.developersdex.com ***
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.