(URGENT) Opening a form with a different recordset than one specified on form_load ?

04-16-2004, 06:10 PM
I have a form that is fully working, which I access by pressing a command button.

The form_load specifies a recordset to open, but...

I want to create a 2nd command button, which will open the same form but using a different recordset...

Can I open the same form while passing a different recordset for it to open (and how do i get this recordset I am passing to override the recordset specified on the actual form_load)?

Hopefully I can, as it will save me having to create a totally new form, which is exactly the same except with a different recordset.

If I cant do it this way, is there anyway on the form_load of the actual form that I could specify:

(ie. If user used command button 1 on main menu to get there)
If frmMain.cmdButton1 was pressed Then
Open ProperRecordset

(ie. If user used the new command button to get there)
Else If frmMain.cmdButton2 was pressed Then
Open DifferentRecordset


As well as that, I would like it so that if the LoginID (which can be found on frmMain.txtLogin.Text) equals any of the values in the newly opened recordset field LoginID, that the Edit command button would be enabled on the new form everytime it hits one of that users records, otherwise edit button should be disabled....
Is it also possible to do this?

Hope thats clear

Thanks for any help

04-17-2004, 02:05 AM
In a regular module, create a Public variable which will hold the recordset object or query name, that the form will assign as it's recordsource in it's 'FormOpen' event. Don't forget to assign a default value if the public variable is not set.

As each button on the main form is pressed, you set the value of the public variable.

If you want to prevent users from affecting records, simply filter the recordsource as each user opens the form.

04-20-2004, 10:01 AM
Sorry I understand very little of that...

Could you please re-explain ?

04-21-2004, 09:27 AM
What appplication are you developing in?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum