Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ON CLICK subform

Status
Not open for further replies.

cpagano

Technical User
Mar 14, 2008
12
0
0
US
Hi all..

I have what I need "ALMOST"

I have a form with a subform
The subform has a check box..
On click another subform opens with linking information..

What I need is, if the linking information is there, find it, if its not there, add it..

Here is what I have now.. It finds it but if its not there then it just opens as blank..
Does this mess make sense?? Thanks



Private Sub Check28_Click()
Dim stDocName As String
Dim stlinkcriteria As String
stDocName = "STATUSformsub"
stlinkcriteria = "[VISIT]=" & "'" & Me![VST] & "'"
DoCmd.OpenForm stDocName, acFormDS, , stlinkcriteria
End Sub

 
If it is a "true" subform, then you do not need the docmd etc, you set the link values in the subform control Master/Child link fields properties

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
The subform opens another form.. (maybe I shouldnt call the second a subform)

Thanks
 
OK

Not being picky, just trying to be sure I understand your question,

suggest you put code in the onOpen Event of the form which is opened (STATUSformsub)

if me.recordsetclone.recordcount <= 0 then
me.recordsetclone.addnew
me![Visit] = Forms!Sendingformname![VST]
me.bookmark = me.recordsetclone.bookmark
end if

think that should do it

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Thanks
Currently I have the code in the ON CLICK event for the check box on the subform..

Are you suggesting I remove this and add this code to the on open event of the opening form?
Thanks again
 
No, the code to add the record must go in the form you are openning (on open event)

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Im getting an error that it cant find my form..

This is the correct syntax?
me![Visit] = Forms!Sendingformname![VST]
 
Yes, if Sendingformname is the name of your form (which I doubt) you need to substitute the correct form name in place of Sendingformname

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
No no,.. I did that..
not working, says it cant find my form.

UGG!
 
Is the form open?

If not another alternative method is to pass the value of VST in the ,openargs parameter at the end of the docmd.openform

do you know how to do that?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
NO, of course not :)

Thanks for being patient

C
 
OK

DoCmd.OpenForm stDocName, acFormDS, , stlinkcriteria,,,Me![VST]

and change the code I gave you so

if me.recordsetclone.recordcount <= 0 then
me.recordsetclone.addnew
me![Visit] = me.openargs
me.bookmark = me.recordsetclone.bookmark
end if

Note I am not totally sure abount the number of ,,, in the docmd, but the intellisense will prompt you, you are looking for openargs

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top