How to get command button to light only if data is null in subs

  • Thread starter Thread starter DOYLE60
  • Start date Start date
D

DOYLE60

I have a form with three sub forms that I update with a command button called
"Update." The three subforms show bad data that needs to be fixed. I wish a
second command button ("Transfer Data") to light up only if the three subs have
no records. I want this button to light after the "Update" is hit.

Therefore, the user will press the Update button and see the errors, fix the
errors, hit the Update button again, and---if all goes well---hit the Transfer
Data button.

I've tried several things but haven't a clue what I'm doing. Thanks,

Matt
 
DOYLE60 said:
I have a form with three sub forms that I update with a command button called
"Update." The three subforms show bad data that needs to be fixed. I wish a
second command button ("Transfer Data") to light up only if the three subs have
no records. I want this button to light after the "Update" is hit.

Therefore, the user will press the Update button and see the errors, fix the
errors, hit the Update button again, and---if all goes well---hit the Transfer
Data button.

I've tried several things but haven't a clue what I'm doing. Thanks,

I find "light up" a beautiful term, which I will borrow with your kind
permission :-)

If the user actions are as you describe, the decision moment is always
when Update is pressed, right? You can check if the subform has records
by doing (from the main form):

if me!subformcontrolname.form.recordsetclone.recordcount=0 then...

If you want all three subforms to be empty, you can assign the
expression above for each subform to a variable, adding up. Recordcount
is never <0, so if yo add up and arrive at zero, all are empty.

dim nCount as long
ncount=me!firstsubformcontrolname.form.recordsetclone.recordcount
ncount=ncount+me!secondsubformcontrolname.form.recordsetclone.recordcount
ncount=ncount+me!thirdsubformcontrolname.form.recordsetclone.recordcount
'do the lighting
if ncount=0 then btnTransfer.enabled = true

You may set focus to it as well, or make it the Default button so it
fires when the user presses Enter. Those are little niceties in the
interface.
 
Thanks Bas. It worked very well.

Matt


I find "light up" a beautiful term, which I will borrow with your kind
permission :-)

If the user actions are as you describe, the decision moment is always
when Update is pressed, right? You can check if the subform has records
by doing (from the main form):

if me!subformcontrolname.form.recordsetclone.recordcount=0 then...

If you want all three subforms to be empty, you can assign the
expression above for each subform to a variable, adding up. Recordcount
is never <0, so if yo add up and arrive at zero, all are empty.

dim nCount as long
ncount=me!firstsubformcontrolname.form.recordsetclone.recordcount
ncount=ncount+me!secondsubformcontrolname.form.recordsetclone.recordcount
ncount=ncount+me!thirdsubformcontrolname.form.recordsetclone.recordcount
'do the lighting
if ncount=0 then btnTransfer.enabled = true

You may set focus to it as well, or make it the Default button so it
fires when the user presses Enter. Those are little niceties in the
interface.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
 
Back
Top