If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Open Form Artificially Blank
Hi,
I have a form bound to a set number of records. I do not want the user to be able to add any new records. I have a combo box with some VB code to allow the user to select one of the records to be able to edit it. When they first open the form, it shows the first record's info. I would prefer that all the fields were blank until they use the combo-box to select a record. How can I do this? I don't want to create a dummy blank record and make that open first, because then I have an empty record floating around to mess up my reports. Also, I don't want the user to be able to edit that "dummy" record and give it info. What do you suggest? Thanks!!! John Schping |
#2
|
|||
|
|||
Open Form Artificially Blank
On Sun, 17 Jan 2010 11:26:01 -0800, jschping
wrote: Hi, I have a form bound to a set number of records. I do not want the user to be able to add any new records. I have a combo box with some VB code to allow the user to select one of the records to be able to edit it. When they first open the form, it shows the first record's info. I would prefer that all the fields were blank until they use the combo-box to select a record. How can I do this? I don't want to create a dummy blank record and make that open first, because then I have an empty record floating around to mess up my reports. Also, I don't want the user to be able to edit that "dummy" record and give it info. What do you suggest? Thanks!!! John Schping About the only way would be to base the form on a Query which you can be sure returns no records. Say you have an Autonumber primary key (that the combo box uses to select the record); you could base the form on a query selecting IDField = 0 as a criterion (after assuring yourself that there is no 0 record!!) The code in the combo box would then change the form's recordsource to the single record containing that value. This has the additional advantage that the form is never populated by more than one record, making it more efficient - especially if you have a split application or a SQL/Server network backend. -- John W. Vinson [MVP] |
#3
|
|||
|
|||
Open Form Artificially Blank
Well, for me I would use the form's properties.
1. Allow Edits 2. Allow Deletions 3. Allow Additions 4. Data Entry You can use the OnOpen event or in the form's properties to set 1 or 2 or 3 to "No" and set Data Entry to Yes. Setting DataEntry to "Yes" will show blank record on the form and AllowEdits to "No" will prevent data entry. Setting certain combination may hide your controls but you can use the search combo box in the form's header to change the form's properties "Allow Edits/Additons" and "Data Entry". (do not place the search combo in the detail section of the form) jschping wrote: Hi, I have a form bound to a set number of records. I do not want the user to be able to add any new records. I have a combo box with some VB code to allow the user to select one of the records to be able to edit it. When they first open the form, it shows the first record's info. I would prefer that all the fields were blank until they use the combo-box to select a record. How can I do this? I don't want to create a dummy blank record and make that open first, because then I have an empty record floating around to mess up my reports. Also, I don't want the user to be able to edit that "dummy" record and give it info. What do you suggest? Thanks!!! John Schping -- Please Rate the posting if helps you. Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201001/1 |
#4
|
|||
|
|||
Open Form Artificially Blank
Hi,
Thanks for replying. Your idea sounds great, especially since it will be a split database over a network. What code do I use to change the SQL behind a forms recordset? Thanks, John Schping "John W. Vinson" wrote: On Sun, 17 Jan 2010 11:26:01 -0800, jschping wrote: Hi, I have a form bound to a set number of records. I do not want the user to be able to add any new records. I have a combo box with some VB code to allow the user to select one of the records to be able to edit it. When they first open the form, it shows the first record's info. I would prefer that all the fields were blank until they use the combo-box to select a record. How can I do this? I don't want to create a dummy blank record and make that open first, because then I have an empty record floating around to mess up my reports. Also, I don't want the user to be able to edit that "dummy" record and give it info. What do you suggest? Thanks!!! John Schping About the only way would be to base the form on a Query which you can be sure returns no records. Say you have an Autonumber primary key (that the combo box uses to select the record); you could base the form on a query selecting IDField = 0 as a criterion (after assuring yourself that there is no 0 record!!) The code in the combo box would then change the form's recordsource to the single record containing that value. This has the additional advantage that the form is never populated by more than one record, making it more efficient - especially if you have a split application or a SQL/Server network backend. -- John W. Vinson [MVP] . |
#5
|
|||
|
|||
Open Form Artificially Blank
On Sun, 17 Jan 2010 20:03:01 -0800, jschping
wrote: What code do I use to change the SQL behind a forms recordset? Me.RecordSource = strSQL where strSQL is a valid SQL statement returning the fields that you want on the form. -- John W. Vinson [MVP] |
#6
|
|||
|
|||
Open Form Artificially Blank
Thanks!!
"John W. Vinson" wrote: On Sun, 17 Jan 2010 20:03:01 -0800, jschping wrote: What code do I use to change the SQL behind a forms recordset? Me.RecordSource = strSQL where strSQL is a valid SQL statement returning the fields that you want on the form. -- John W. Vinson [MVP] . |
#7
|
|||
|
|||
Open Form Artificially Blank
You may want to use a main form and subform
The main form is unbound and has the combo box to select a record. Default value is null The subform (your current form minus the combo box) is bound to your table and linked to the main form by the combo box. When you start the subform will be empty. When you select a record in the combo box of the main form the subform is populated "jschping" wrote in message ... Hi, I have a form bound to a set number of records. I do not want the user to be able to add any new records. I have a combo box with some VB code to allow the user to select one of the records to be able to edit it. When they first open the form, it shows the first record's info. I would prefer that all the fields were blank until they use the combo-box to select a record. How can I do this? I don't want to create a dummy blank record and make that open first, because then I have an empty record floating around to mess up my reports. Also, I don't want the user to be able to edit that "dummy" record and give it info. What do you suggest? Thanks!!! John Schping |
Thread Tools | |
Display Modes | |
|
|