Link to home
Start Free TrialLog in
Avatar of madeatmidnite
madeatmidnite

asked on

How to move from one subform to another

I have a form with 2 subforms (Meds) and (DeletedMeds).  I run an append query and then a delete query to move a Med record to DeletedMeds and then delete it from the first subform.  All this is done with a checkbox.  

Now I want to add code to the checkbox code to move to the DeletedMeds table where I have the cursor move to the (Reason) field.  So ideally, the person would check the  checkbox on the Meds subform that would append the medicine to the DeletedMed subform and then and then would automatically go to the Reason field without any other clicks etc.  The only thing I can't figure out, is how to move from one subform to another.

Any help greatly appreciated.

Carrie
Avatar of will_scarlet7
will_scarlet7

Hi Carie,
I think you might be able to use a setfocus command in the After Update event of your check box (presumably the sme event that you are using to run your queries). Perhaps something like this:

Me!YourSubform!NameOfTextBox.Setfocus
Sorry Carrie for spelling your name wrong above...
Small comment about database construction: You should never delete records that are to be used again. Rather, you should just flag them in an extra field and thus you can separate the "deleted" ones from the active ones....

Sorry to be so obnoxious...

M
Carrie,
I ran some tests a found that my suggestion was incomplete. You will also need to run a second setfocus command to set the focus to the subform after running the line setting the focus to the control. Like this:

Me!YourSubForm!NameOfTextBox.Setfocus
Me!YourSubForm.Setfocus
ASKER CERTIFIED SOLUTION
Avatar of will_scarlet7
will_scarlet7

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madeatmidnite

ASKER

Will --thanks for the quick response. no worries about the name spelling :)

It still isn't liking it.  I put it into afterupdate, but it seems to want to run it first.  If I just hit end instead of debug, then it will run the way it always used to.



Moother,

how would I go about flagging them in an extra field?  Would I just base the deleted meds subform on the same table as the meds?  Tell ya what, since I am now asking two questions in on, I will post another question for this one.


Carrie
What event are you using to run the update queries? What is the error message that you are getting?

Can you post your code here so I can see if I can determine what might be causing the errors?
Trying out something -- let ya know soon if it works.

thanks
carrie
Basically, you should add an extra (integer) field to your table and call it "deleted" or something like "active". Make the default value 1. Then, insted of deleting and updating, just change the default value to 2, or 0, or whatever you want...

Then you just modify your queries to show which is "deleted" and which isn't.

That will save all the complex work you're doing now with just one update query and one form.recalc

Try find some good links on database construction (especially normalization) and you'll find it will make your life easier.

Good luck....

M
"change the default value" should read "change the value"
As for the jump you want to accomplish, you can just open up a small form that has 1 text box and ask the user to confirm the delete with a reason. then recalc your form.