Blank Form at Load

roxtonsgirl

Registered User.
Local time
Today, 06:00
Joined
May 14, 2009
Messages
10
Hello all,

I'm something of an Access 2007 newbie. I'm working on an invoicing db for work. I've got a Search Invoices form that is bound to the main invoice table. Basically I want users to be able to search invoices entered and update them if needed. They search the invoices through a combo box. Since the form is bound I understand that my form will always open with the 1st record in the table. However, I'm hoping that there's a way to have the form cleared when opened so no one accidentally edits the wrong record. I'm thinking from reading on this forum that I can set an event for "On Load" using this command: DoCmd.GoToRecord , , acNewRec

However, since I don't know VBA at all, I'm not sure how to place the code. Can anyone assist with this?

Thank you,
Steph
 
Since this is a form event, you can simply paste the code into the code window.

From Form Design View, press <Ctrl> + <G>. This will take you to the code window, then paste this into the window:

Code:
Private Sub Form_Load()
 DoCmd.GoToRecord , , acNewRec
End Sub

Since this is Access 2007 the database file has to be in a folder that has been declared "Trusted" in order for code to run. Have you done that yet? If not, to trust your folder, click:

  1. Office Button (top left)
  2. Access Options (bottom of dialog)
  3. Trust Center (left)
  4. Trust Center Settings (button)
  5. Trusted Locations (left)
  6. Add new location (button)
 
You can't use new record as its meant to be a search why not use a list box to display the invoices and a control on the form to enter search criteria when a invoice is then selected you could have a command button to display the invoice.

Maybe something like the attached screen shot.

Good luck John :)

Ahhh... re-read missed the point but there you go... But then again if its a search form why create "new records" surely you just want to display what has already been entered otherwise you could end up with blank "records" if the user makes the wrong choise and enters data into any of the controls on the form...
 

Attachments

  • invoice.jpg
    invoice.jpg
    75.7 KB · Views: 1,153
Last edited:
Since this is a form event, you can simply paste the code into the code window.

From Form Design View, press <Ctrl> + <G>. This will take you to the code window, then paste this into the window:

Code:
Private Sub Form_Load()
 DoCmd.GoToRecord , , acNewRec
End Sub

Since this is Access 2007 the database file has to be in a folder that has been declared "Trusted" in order for code to run. Have you done that yet? If not, to trust your folder, click:

  1. Office Button (top left)
  2. Access Options (bottom of dialog)
  3. Trust Center (left)
  4. Trust Center Settings (button)
  5. Trusted Locations (left)
  6. Add new location (button)

Thanks missinglinq! I've been pulling my hair out for 2 days trying to resolve this and figure out the code. I didn't realize about the trusted site either, so excellent forward thinking there. :D
 
Still fail to see why a combo box would be a choise for search but hey hooo it limits what they can search.. and if you have not applied restrictions on your form will make unwanted records...
 
John,

Using a combobox to search for a particular record is kind of SOP in Access. That's why it is one of the options presented by Access when you create a combobox using the wizard.

And moving to a new record is also kind of SOP when you want a 'blank' record when doing this. A new record is not created unless data is actually entered in it. In other words, moving to a new record does not equal creating a new record.

Glad we could help you, Steph!
 
Ok fair enough but say you have a lot of invoices and want to serach via multiple criteria? Number, date, partial title a combo box can't do this and as a given the records are only going to grow in number so a drop down list no matter how big you make it will ultimately become limiting.

As for not creating a new record this is true providing that default values have not been set for fields or that your user does'nt enter information into the form in error thus creating a record instead of searching.

Ultimately its your choise I have just found by experiance it is more friendly to have a dedicated search form that you cannot enter data into for search purposes.

good luck John
 
In the case of multiple search fields this is true, but no mentions was made of this by the OP.

And no, having Default Values set up for one or more fields still won't create a new record; the record is not dirtied thus creating a new record until other data is entered. And yes, if the user enters anything, a new record will be created. But this is preferable to accidentally modifying an existing record, which is the OP's, as well as many other developers, concern.

It is, of course, a matter of choice.
 
And no, having Default Values set up for one or more fields still won't create a new record; the record is not dirtied thus creating a new record until other data is entered.

My bad you are right thinking of something totally unrelated :o
 
Hi ALl. I am a complete newby to access. The only way I can get this to work is if I change the "Data entry" option to yes but then it does not show any of my records. What am I doing wrong? Please help :o
 
Thanks John, have done it step by step, still no luck. Must have done something wrong elsewhere.
 
"Data Entry" should be set to "No" (see help for Data Entry Property).

"Allow Additions" should be set to "Yes".

Oh, and it should be a bound form, right?
 
Thanks guys, working now. Was pasting it into the subform instead of the main form. My Bad...
 
when you say "no luck" what is happening?
what query is you table based on?

the problem is, is that if it's based on a non-updateable query, then none of this will work.

open the query directly, and try to edit things. (or even just see if there is a new item asterisk at the bottom).

if you cant edit, you have a non-updateable query.
 
Since this is a form event, you can simply paste the code into the code window.
...

Code:
Private Sub Form_Load()
 DoCmd.GoToRecord , , acNewRec
End Sub


Thanks a lot! I have been trying to figure this out for a couple of minutes!:D
 

Users who are viewing this thread

Back
Top Bottom