Topics Search

VBA code to open MS Access form to new, blank record

VBA code to open MS Access form to new, blank record
Views: 199
I want to open a form in Access 2007 (on WinXP) by clicking a button on a different form, and I want the form to open with blank fields, to create a new record in the underlying table.

My code is as suggested in the five-year-old posting, but it doesn't work:
Sponsored Links:

Similar posts...

 

Is it possible to open a form to a blank record?

Is it possible to open a form to a blank record? Icon
Currently I have inserted blank records with record IDs of 99999 and just linked the "open form" button to the last record, but I would like to be able to open it to just a blank record if I was just opening the form. My boss is asking and I don't know.
 

Filter Without Saving the Data Used

Filter Without Saving the Data Used Icon
I have a search form that consists of text boxes and combo boxes. If I type 10001, for example, into the Document Number text box and click my search button, it searches and pulls up the records just fine; however, when I exit out of the form and check my table, 10001, has been added as a new record.

I do not want this to happen. I had written a vba code to set the form to read-only thinking that would help, but it hasn't.

Here's the code I used to make the form read-only and for it to open to a blank form:

[CODE]

I have a couple other forms as well, such as an add record form, an update record form, and a delete record. I made separate forms, so we could better control our documents as all are restricted with passwords, except the search record form.
 

FilterOn property...unable to add new record when opening form with the filter on??

FilterOn property...unable to add new record when opening form with the filter on?? Icon
I have a form with the record source set to a query with a couple thousand records. There are two places to open this form in my program. One from the switchboard and it displays all records in the query.

Another from a form that filters to meet a specific Employee Number. When I open the form from the switchboard (all records) the last row is a blank record. When I open with the filter on, the blank record does not exist. I have "Allow Additions" set to true, so what is causing this behavior?

Private Sub btnAddNewRecord_Click()
DoCmd.GoToRecord , , acNewRec 'goes to open record
Me.cboDriverNumber.SetFocus 'sets focus to combo box
End Sub

It works fine when I open from the switchboard (with all records displayed from the query). It does not work and there is no blank record when I open it from the form with the filter applied.
 

How to open a blank form?

How to open a blank form? Icon
Can anyone tell me how to start with a blank form when I open my access database? When I open it now it opens with the last record entered
 

VBA code for my unbound Search form.

VBA code for my unbound Search form. Icon
I have a search form, which is now unbound from my table, and by that I mean I have gone and set the form's Record Source to remain blank. I have also gone and set the Control Source ofeach text box and combo box to also remain blank.

I did this because when I would search for a record by a particular field, by Document Number for example, the data I typed into the text box, or selected in the combo box, would then bestored as a new record in my table, which I did not want.

So, by doing this my Search button no longer works.

Now, do I need to write a VBA code consisting of information that will let me search by each field? For instance, in my code do I need to include information that will let me search by theDocument Number, and/or File Type, and/or Revision, and/or Project, and/or Manufacturer, and so forth?

I have been searching all day for example VBA codes for searching, but have not been successful.
 

Calling a form that is not open from VBA in Access 2000

Calling a form that is not open from VBA in Access 2000 Icon
I'm trying to call a form and get/set properties from VBA code in Access 2000. The code runs fine when the form is open, but when the form is not open in the db, I get the following error:

"Microsoft Office Access can't find the form 'ContactForm' referred to in a macro expression or Visual Basic code."

'ContactForm' is the name of the form I'm trying to get/set the properties on.

Here's the code I'm running:
 

VBA code for Command buttons on child form

VBA code for Command buttons on child form Icon
I am very new to Access 2003 and I've run into a problem with the command buttons on one of my forms. I have a main form that has a command button that opens up a second form, on the second form my Record Navigation 'go to previous record' and Record Navigation 'go to next record' buttons do not work, I receive the error: You can't go to the specified record.

However, when I open this second form up by itself these buttons function as they should.

@AccessMSSQL mentioned that when I open the second form through the command button, this may cause only one record to be displayed so I can't move to next or previous.
 

MS Access go to specific record when open a form vba

MS Access go to specific record when open a form vba Icon
I am working on a form that is bound to a table with user’s name. I need to be able to go to specific record base on a text box value which contain user login name, if there is no match then go to the new record for new entry. I want this to happen when the form open.

The purpose of this is due to a multi-user environment application that I want the user to see his/her profile when open the form.
 

Add record from Excel VBA Form to Access DB

Add record from Excel VBA Form to Access DB Icon
I've been looking for the code to add a Record to an Access Database.

The user enters the info in a VBA Form and I want to transfer this data to Access.

How can I do this?
 

VBA search code

VBA search code Icon
Having a little trouble with some VBA code designed to grab a number from a form (MRN) then use this data to find the corresponding data in a table making a small change to that record (changing a checkbox to true).

The table opens but only the first record is updated. The code works well as a standard VBA search code on another form.