Full Version: Stopping Record being Automatically Selected
UtterAccess Forums > Microsoft® Access > Access Forms
samhastings
I would like my form NOT to display the first record by default when the form is opened.
I have looked through the properties for the form but haven't found a solution.
Can anyone suggest what I can do?
Thanks!
Sam
danishani
Welcome to UA Sam!!! frown.gif
That do u want to be opening with? U want the form to be opened in "addin new record" stage?
In the Form_Open event:
DoCmd.RunCommand acCmdRecordsGoToNew
Or
DoCmd.GoToRecord , , acNewRec
HTH
Daniel
samhastings
Sorry I could've worded my original message much better.
That I want is for nothing to be selected when the form is opened.
Ocouldn't get the code you gave me to work, unfortunately.
danishani
Did u place the command in the Form_Open event of your form?
It should work...
Daniel
samhastings
It gave me error 2105:
You can't go to the specified record"
This happens with both lines of code.
danishani
If u just open the form normaly, can u add a new record manualy?
aniel
samhastings
No...and actually I don't want to be able to add a new record.
didn't realise that's what your code was intended to do.
All I want is for the form to appear blank when opened instead of a record being loaded by default.
danishani
hmmm sorry that i did not explain what the code did... but I assumed that was, what u needed...
nyway, whats the purpose of showing a blank form?
U can open a form without any recordsource set to it, then u will see a blank form.
FOr use a form with UNBOUND controls on it.
HTH
Daniel
JVanKirk
I am not sure why you would want the form to appear blank? The code above is giving you an error because you have Allow Additions set to No which is fine since you don't want to allow additions. However, Access is going to display a record since there is not a new record to display. There are a couple of ways I could see to accomplish what you want I suppose, one would be to have the form open with the font color set to the same as the backgroundcolor of the control and then on a certain event or maybe by clicking a View records button change the font color to a suitable viewing color. That would probably be the easiest. Another way would be to create a "blank record" and have it displayed when the form opens.
ason
samhastings
Sorry I should've explained my situation better.
I have a form with a subform which is used to search through a list of records. The main form contains a drop down combo box with several options in, which when selected filters the records in the subform down to those applicable to the selection made.
The only thing is, the subform automatically opens a record even without something being selected from the main form, which is confusing and looks unprofessional.
I'll have a play about a bit more, but if you have any other ideas please let me know - thanks frown.gif
-Sam
danishani
Hi Sam,
That explains a lot more, u need to set the criteria of the query of yr subform to the combobox selection, so when nothing is selected, nothing will show in yr subform.
If u need more info on this, please ask...
Daniel
JVanKirk
That does help, and explains why you would want a blank SUBform.
ason
Sartek
He's having the EXACT same problem I'm having..
sing an unbound combobox to select the record to be displayed in a subform (located on a tab control no less.) the subform by default shows the first record in the query used to populate it. when a record is chosen in the combox, the subform switches to the correct information... just wish I get the subform to show up empty when I open the main form.
in my attachment is a version of this using a query with search criteria and subform refresh.. thsi causes teh tabs to disappear for somereason..
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.