New record problem in sub-form

D

dinaC

I have main form based on a table, linked to a sub-form based on a junction
table. Everything is working pretty well except: The PK of the junction table
is an auto-number field and it is displayed in the subfrm. When I tab from
the main form to the subform, the autonumber field (PK of subfrm) is blank
until I enter a record into the Dr field (which is a look-up to the Dr table)
at which point the focus goes back to the auto-number field and a new
auto-number appears but instead of creating a new record, the form defaults
back to the first record. The new record is saved but I have to go to it and
continue entering the information.
Any ideas on what's wrong?
 
T

tina

try checking the Tab Order of the form controls, in the form's Design view.
also check the the controls' and perhaps the subform's AfterUpdate events to
see if you have code or a macro running that forces the focus to a new
record in the subform, something along the lines of
"DoCmd.Records.NewRecord".

hth
 
D

dinaC

Thanks, Tina! I had forgotton I'd set a macro to run "on click" to refresh
data when a new Dr was entered. I removed it and now it works. Which leads to
the next question: I created a Command button to open a form and add a new Dr
when the Dr wasn't in the list. That's why I created the macro in the first
place--because after the Dr was added, it needs to display in the list and I
was following instructions to "refresh". But it didn't work, not sure how to
fix. I'd like to be able to add a new Dr record without leaving the form.
 
T

tina

you don't need to refresh the entire form, just the "list" - i'm guessing
you mean a listbox control or combobox control. try adding code to the Enter
event of that control, as

Me!ControlName.Requery

replace "ControlName" with the actual name of the control, of course.

hth
 
D

dinaC

Got it. Wish I'd tried this site sooner. I've spent hours and hours figuring
out many to many relationships and how to get my report and forms to group
the records correctly. I'm sure I'll be back. Thanks!
 
T

tina

you're welcome :)


dinaC said:
Got it. Wish I'd tried this site sooner. I've spent hours and hours figuring
out many to many relationships and how to get my report and forms to group
the records correctly. I'm sure I'll be back. Thanks!
 

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