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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check if there is record in subform to enable edit

Status
Not open for further replies.

BMKanun

Technical User
Sep 27, 2010
20
MK
Hi,
I have subform in main "Employees" form presenting Holidays (StartDate, NrDAys, Comment..)
In the form (OnLoad) permitions
AllowAdditions
AllowDelitions
AllowEdits
are set on False. Particular operator (OperatorID) can do change with Commandbuttons event code setting them True, before Adding new record, edit or delete record, respectively.
Problem:
When the subform has no records, clicking Edit or Delete record is causing "Runtime error 2105. You can't go to specified record!".
Question: What would be the simplest way of checking if there is any record in the subform to continue setting permitions and perform task or exit?
Thanks,
BM
 
You could add error handling code that checks for 2105 and pops up a message there are no records. Or look for records to enable/disable the command buttons.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
1) I guess you could do a DCOUNT on the sub forms, record set. Check to see if > 0
or
2)Create a record set for that forms records. You can see if it is a EOF on the subform for the record set and do what you need to do at that point in time.

Remember when... everything worked and there was a reason for it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top