subforms

  • Thread starter Thread starter nydia
  • Start date Start date
N

nydia

I created a main form and want to add a command button to
open up another form ( a questionaire).

I added a command button and chose the open form, then i
chose for it to open the form for the specific person,
based on client ID. here is the problem, the form i want
it to open is a questionaire (that will be filled out
atleast 4 different times), when i click on the command
button, it opens up a form, but you can't see who the form
is for (i won't be able to remember the clientid's), so i
need to be able to see who the form is for.how can i do it
so when i click on the command button, it opens the form,
but has the client information (name etc on the top)

also, if i try to fill out the form and don't put in the
client #, it will not save it to that client. is there a
way it will automatically use the clientid of the record
that i was on when i clicked on the command button. hope i
explained this ok, any help is greatly appreciated
thanks :)
 
Nydia

You can pass information from calling form to called form
by using the OpenArgs parameter on the DoCmd.OpenForm method.
Within the called form, the information is accessed through
the variable OpenArgs and you will then have to
programmatically retrieve all the information you require
and display as appropriate in the form.

Hope That Helps

Gerald Stanley MCSD
 
Nydia

You can pass information from calling form to called form
by using the OpenArgs parameter on the DoCmd.OpenForm method.
Within the called form, the information is accessed through
the variable OpenArgs and you will then have to
programmatically retrieve all the information you require
and display as appropriate in the form.

Hope That Helps

Gerald Stanley MCSD

Might somebody elaborate with a Code Sample?
 
Might somebody elaborate with a Code Sample?

DoCmd.OpenForm strDocument, OpenArgs = "Foo~Bar~Zap"

and then in the Form's open event

Dim strArgs() As String
strArgs = Split(Me.OpenArgs, "~")


strArgs(0) will be "Foo", strArgs(1) will be "Bar" and so on.
 
I'm not an expert at this, and this doesn't make any
sense, can someone please walk me through it
 
I'm not an expert at this, and this doesn't make any
sense, can someone please walk me through it

Perhaps you could explain the context and what you're trying to
accomplish, so someone could try to help with the specific problem.
 
I have a form with a command button that opens up a
questionaire. They are linked together by clientID. But,
when you click on the command button, it opens up the
questionaire and hides the name, address on the other form
and if a clientID is not entered into the questionaire, it
will not show up the next time you open up the questionair
for that client. I used the wizard to create this button
and below is the code it uses on click. Can someone
please help me fix this. I'm obviously not an expert and
dont understand all the terms, so can you please be
specific when helping, it's greatly appreciated.

Private Sub Command29_Click()
On Error GoTo Err_Command29_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmWorkBehaviorsQuestionaire"

stLinkCriteria = "[ClientID]=" & "'" & Me![ClientID]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command29_Click:
Exit Sub

Err_Command29_Click:
MsgBox Err.Description
Resume Exit_Command29_Click

End Sub

..
 
I have a form with a command button that opens up a
questionaire. They are linked together by clientID. But,
when you click on the command button, it opens up the
questionaire and hides the name, address on the other form
and if a clientID is not entered into the questionaire, it
will not show up the next time you open up the questionair
for that client. I used the wizard to create this button
and below is the code it uses on click. Can someone
please help me fix this. I'm obviously not an expert and
dont understand all the terms, so can you please be
specific when helping, it's greatly appreciated.

Have you considered using a Subform rather than using code to open a
second form? If you do so, using ClientID as the master/child link
field, no code is needed AT ALL - and you can still see the name and
address on the mainform while viewing the questionnaire on the
subform. Note also that the client's name and information should not
exist in the questionnaire table *at all* - you can display it on the
questionnaire form, if you in fact use a standalone form rather than a
subform, but it would not be good design to store that information
redundantly.
 
The reason I wanted to use a command button to open this
subform is because the questionaire is about 20 questions
and then a comments line, the users are not very
comfortable using a pc, so having to use the scroll bars
to navigate the questionaire may be confusing for them.
 
The reason I wanted to use a command button to open this
subform is because the questionaire is about 20 questions
and then a comments line, the users are not very
comfortable using a pc, so having to use the scroll bars
to navigate the questionaire may be confusing for them.

Well, your milage may vary but some users will get confused by opening
a separate form. Don't call it a subform if it's not - if you're using
a command button to open a form, you can call it a "pop up" form.

What specific problems are you having? You asked about using OpenArgs
- what do you want to do with it?
 
Back
Top