On form load check subform field

G

Guest

Hi anyone

I would like help with the following:

I have a supplier form and a cmd button that opens a supplier order form. On
clicking this button, the form it is to open i want it to do the following
but not sure how to do this:

form load, first check the subform which has a field called stock no, this
field lists all stocknos for the supplier. if supplier has no stock lines
it shows now value in the list.
When you open, check that field and its list content, if nothing is in the
list then I dont want you to open the form just display a msgbox saying no
order lines else open the form as normal.

Anyone that can help would appreciate this very much.

Thanks in advance.
 
M

[MVP] S.Clark

The subform has a recordsource, which is filtered by the Main form, based on
the linkmasterfields and linkchildfields property of the subform.

If Dcount("*", "Recordsource", "FieldName" & [linkmasterfieldname]) = 0 then
msgbox "No Records Found"
else
'Do whatever you do with a record found
end if

You could also use recordsetclone, or check the value of
Forms!SubformControlName.Form!Controlname

Any option will do.
 
G

Guest

Thnaks, will give it a go

[MVP] S.Clark said:
The subform has a recordsource, which is filtered by the Main form, based on
the linkmasterfields and linkchildfields property of the subform.

If Dcount("*", "Recordsource", "FieldName" & [linkmasterfieldname]) = 0 then
msgbox "No Records Found"
else
'Do whatever you do with a record found
end if

You could also use recordsetclone, or check the value of
Forms!SubformControlName.Form!Controlname

Any option will do.

--
Steve Clark, Access MVP
http://www.fmsinc.com/consulting
*FREE* Access Tips: http://www.fmsinc.com/free/tips.html

Saj said:
Hi anyone

I would like help with the following:

I have a supplier form and a cmd button that opens a supplier order form.
On
clicking this button, the form it is to open i want it to do the following
but not sure how to do this:

form load, first check the subform which has a field called stock no, this
field lists all stocknos for the supplier. if supplier has no stock
lines
it shows now value in the list.
When you open, check that field and its list content, if nothing is in the
list then I dont want you to open the form just display a msgbox saying no
order lines else open the form as normal.

Anyone that can help would appreciate this very much.

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top