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

Subform always opens with a record...I don't wan this!

Status
Not open for further replies.

NRK

Technical User
Feb 13, 2002
116
0
0
US
I have a subform that is based off a Category field in my Main form. I want to open my form and see the subform empty. Instead, it is always populated with the first record, regardless of Category selection.

Is there a way to have the default be Null on open? Or, is there any other solution?
 
Try Changing the DATA ENTRY option in the subform properties to YES. This should bring up a blank record every time.

jahmed
 
Try Changing the DATA ENTRY option in the subform properties to YES. This should bring up a blank record every time.

j ahmed
 
jahmed,
Thanks for the idea. Unfortunately, I had already tried that. It works in the sense that the subform does not populate with any records, but with Data Entry on Yes, users cannot look up any records.

Or, is there something I am missing?
 
Change Data Enty back to NO and try inserting this into the Event Procedure in the OnLoad Property of the form:

DoCmd.GoToRecord , , acLast

This ought to work.
J Ahmed
 
Tried that...opens with the last record in the set highlighted.

To clarify, if needed:
When I open my main form, the subform is populated with 4 records. These records have a category which is listed first within my table and/or query. Even though my combo box on my Main form (populated with all the Categories) is empty. The subform still is populated with these first 4 records.

This seems like a simple problem, but so many times I find that the most simple problems in Access require the most creative solutions.

Should anybody have any ideas I would greatly appreciate it.
 
My personal opinion is "Don't bind your controls to the data". Use a FormState approach i.e. SelectState - enter a value in a look up control. Grab the appropriate record values and put them in the controls, Set EditState. When finished run update query (or append query if in AddState) etc. JHall
 
In your subform data tab properties, do you show a link child and a link master common field? I have several DB's that have a form & subform and when I call up the master form both forms come up ready for data entry, but you can also go back to edit and view the previous entries & they come up together (I think because of the child & master link entries in the property). I also have a command button that after I finish entering the data in both areas of the form that closes the form, then opens it again and goes to a new record (this close and open part may be unnecessary, but maybe the go to "new record" has some substance.) Just a thought.
 
JHall,
I am interested in your solution. Would you please expand upon it a little bit more. I am unsure if I know exactly what you are referring to...

Thanks!
 
You are probably already familiar with the concept of query by form, what I'm suggesting is similar. When you first open a form you are in SelectState. One of the controls on your form is the key field and is enabled (more controls can be used but this is the simplest example). The user enters a value. At lost focus for that control you create a recordset with a select query looking for that key value. If it is found then you enable and populate any editable control/fields and a save or cancel button on the form and enter EditState. If the value was not found you throw a msgbox and inform the user and give them the options of adding the record or reentering the SelectState. When the save button is clicked, if you are in EditState you run an update query against your table(s), if in AddState you run an insert query (append) instead. If they attempt to enter the select control again you handle that in whatever way is appropriate for your needs. If you need more clarification let me know. Incidentally, you can dynamically bind your records to a recordset recordsource in Access2000 (at least that's what I've read). JHall
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top