Command Button to Open Subform in New Window

ejf071189

New member
Local time
Today, 10:03
Joined
Jun 12, 2008
Messages
9
Is there a way to create a command button that will open a subform in a new window by default. I do not want the subform to be visible on the main form at any time, and like in most subforms, there is certain data that I want to be automatically sent from the main form into the subform.

Preferably I would like a way to do this in a way supported by access's gui w/out doing any coding, as I am just learning access, but if coding is the only way to achieve this, then I am open to learning. Just try to bare with my incompetence if I don't understand at first. :)

Thanks for any help in advance.

--Evan
 
Hello Evan!

Look at "DemoAnotherFormA2000.mdb" (attachment).
For you "Form1" and "Form2".
Open Form1 and see.
Look at VBA, Relationhips, Modules.
 

Attachments

Thanks for the reply MStef, that seems to be exactly what I'm trying to accomplish.

Unfortunately, I'm having a little bit of trouble understanding though. The command button in form1 opens up form2, but behaves like a subform in that the keys are linked. Even though I have my relationships setup between my tables, whenever I use the command button to open up the second form, it doesn't automatically import the data from form1's table's key to form2's table's equivalent field. Instead when I open form 2 it just goes directly to the first row of its table.

Is there anyway you can clearly outline how this is done; sorry to be such a pest but I really just started learning access for my job earlier this week.

Thanks again!
 
Ok, I tried comparing a little more, and I've almost got it working (I think).

When I open the second form from a saved a record of the first form, rather than carrying the key value over, it just puts in "0" every time. Then as I input data, this value never changes and eventually I get an error saying the record can't be saved because the value 0 isn't found on the client table.

Here is the code:
Private Sub Command86_Click()
On Error GoTo Err_Open_AccountsSubClients_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "AccountsSubClients"

stLinkCriteria = "[ACCT_Owner]=" & Me![c_id]
DoCmd.OpenForm stDocName, , , stLinkCriteria
formOpen = "o"
Exit_Open_AccountsSubClients_Click:
Exit Sub

Err_Open_AccountsSubClients_Click:
MsgBox Err.Description
Resume Exit_Open_AccountsSubClients_Click

End Sub
ACCT_Owner is a long integer number value on the second form for the "Accounts" table, and c_id is the autonum key on the first form for the clients in the "Clients" table. The relationships are setup properly.
 
Ok, for whatever reason, the default value for ACCT_owner was set to 0, so that explains why it kept going to 0 in my previous post. But the rest of the problem still stands. In your example, the f11 column doesn't actually get filled until you tab enough to get to the next record, but I can't even make a new record because it keeps demanding something be put into ACCT_owner.

Any ideas?
 
In my Demo the field F11 will be populated in Form_BeforeUpdate Sub.
 

Users who are viewing this thread

Back
Top Bottom