Specifying Control>Open SubForm

OxDavis

Registered User.
Local time
Today, 10:30
Joined
Jul 14, 2005
Messages
74
In setting up my DB I was thinking it might be convienient to open my data entry forms within the switchboard interface, i.e. you click Enter Client Data and frmClientData opens up in the switchboard form. I know there has to be a way to specify which control the form shows up in, but I am ignorant of the specific VBA code. Does anyone have a bit of code they are willing to share?
 
Creat an unbound subform on your mainform (called child1) for eg and set its visible property to false (other wise and ugly white blank appears when you open your switchboard.
Create a command button and enter the following code in the on_click event
Code:
With me.child1
.height = (enter required height)
.width = (enter required width)
.sourceobject = (the name of the form in "" you want to display
.visible = true
end with

Regards

Jon
 
Can I specify how I want the form to open format wise? Here is what I have:

Code:
Case conCmdOpenFormAdd
            With Me.chiSwitch
                .SourceObject = rs![Argument]
                .Visible = True
            End With

How can I get the form to open in "acAdd" mode through this code? Sorry again, I am a VBA tyro.:D
 
Here is what I tried with no success:

Code:
Case conCmdOpenFormAdd
           With Me.chiSwitch
                .SourceObject = rs![Argument]
                .Visible = True
            End With
            With Forms!frmCM
                .DataEntry = True
            End With

I even tried setting that property OnEnter, but it says it cannot find Forms!frmCM. Weird. Anyone have a clue they can give me?
 
You are getting your objects mixed up

Sorry bout the delay in getting back to you been away.
The reason that it can't find the form is because you are trying to set a property of a form object instance before you have created it, I take it that "rs" is a recordset object?
If so you can only bind a form to a subform object, you must set the the subforms recordsource property to the recordset object once you have created it by setting the unbound child object source object property to a form in the db. The code would look something like this,
The first would in the on_click event of the command button on the switchboard
Code:
with me.child
.sourceobject = frmCM
.visible = true
end with
You would then need to create your recordset and set it as the frmCM recordsource property in the on_open event of frmCM
Code:
'Code to create recordset object goes here
with me
if .parent.name = "frmSwithcboard" Then
.dataentry = true
end if
.recordsource= rs
end with

Hope this helps

Jon
 
Last edited:

Users who are viewing this thread

Back
Top Bottom