Form open options

G

Guest

Hi all,
I have a form that is serving as an employee task list, it is bound by the
table empl_TaskList - when the form is opened it will filter records based on
the currentUser and whether the task has been marked as "complete" - my
question is, if an employee attempts to open the form and there are no
current tasks for this specific user, is there a way to notify the user that
there are no current tasks, and then give them the option to enter a new one
or close the form? Would this need to be done in the OnLoad event, and if
so, how? Help is always appreciated, thanks!
-gary
 
O

OldPro

Hi all,
I have a form that is serving as an employee task list, it is bound by the
table empl_TaskList - when the form is opened it will filter records based on
the currentUser and whether the task has been marked as "complete" - my
question is, if an employee attempts to open the form and there are no
current tasks for this specific user, is there a way to notify the user that
there are no current tasks, and then give them the option to enter a new one
or close the form? Would this need to be done in the OnLoad event, and if
so, how? Help is always appreciated, thanks!
-gary

Check for .eof in the OnLoad event. Try something like this... I
haven't tested it...

if me.recordsetclone.eof then
iResponse = msgbox("No tasks were found! Would you like to a add a
task?",vbYesNo)
if iResponse = vbYes then
me.recordsetclone.addnew
me.recordsetclone!employee = ' " & employee & " ' "
me.recordsetclone.update
me.recordsetclone.findfirst "[employee] = ' " & employee & " ' "
endif
endif
 
G

Guest

Thank you so much! With a couple tweaks, it works perfectly! However, I
have a follow up question:
I would like this form to open upon the intial load of the system, but have
it be triggered by the primary form that loads. Is it possible to use the
same logic, but instead of having the message box come up with a yes or no
option - have it open if there are matching records, but have nothing happen
if there are not?
Thanks again!
-gary

OldPro said:
Hi all,
I have a form that is serving as an employee task list, it is bound by the
table empl_TaskList - when the form is opened it will filter records based on
the currentUser and whether the task has been marked as "complete" - my
question is, if an employee attempts to open the form and there are no
current tasks for this specific user, is there a way to notify the user that
there are no current tasks, and then give them the option to enter a new one
or close the form? Would this need to be done in the OnLoad event, and if
so, how? Help is always appreciated, thanks!
-gary

Check for .eof in the OnLoad event. Try something like this... I
haven't tested it...

if me.recordsetclone.eof then
iResponse = msgbox("No tasks were found! Would you like to a add a
task?",vbYesNo)
if iResponse = vbYes then
me.recordsetclone.addnew
me.recordsetclone!employee = ' " & employee & " ' "
me.recordsetclone.update
me.recordsetclone.findfirst "[employee] = ' " & employee & " ' "
endif
endif
 

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