Re-Opening a Form

eTom

Registered User.
Local time
Today, 03:18
Joined
Oct 15, 2009
Messages
79
I have built a few simple forms for data-entry at this point, as I'm the only user of my database currently.

At the bottom I've added two buttons, one called "Create &Another" which closes the form and then re-opens the same form so another record can be created. I did this because I don't want the forms to be able to look at existing records. I plan to eventually not being the one entering data and want to limit what the forms are capable of.

The second button is just a "&Done" button that simply closes the form.

I now have the need to enter several records one after another that all use the same data in a few fields. Specifically the "product" field. Since I like to use the keyboard for as much as I can, I want to avoid having to choose the product out of the combo box every time. I want to add a "Create Another With Same &Product" button, essentially.

Can I send the value of the forms ProductID field to the same form when I re-open it? I am looking at the Close action that I have set up, and then the OpenForm action, and I'm thinking that I won't be able to send the value as an argument because the first form has already been closed, right?

Thanks in advance!
 
You're making life hard for yourself by opening and closing the form each time you want to add a record, and Access forms have a property that will do exactly what you want!

In Form Design View, goto Properties - Data and set the Data Entry Property to Yes. Now you will be able to enter new records, but you won't being able to view records that existed prior to opening the form.

As to carrying forward values form one record to the next, in your form, you can use the AfterUpdate event of the control holding your data to set the DefaultValue for the field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each new record.
Code:
Private Sub YourControlName_AfterUpdate()
   Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
End Sub
 
Sorry I should have mentioned that. I am using the Data Entry Property. That was the only way I could find to limit people from being able to view records.

I would use that AfterUpdate on the control, in this case the combo box, that is holding the data, and would... set the Default Value property. I see! Genius!

The reason I'm doing this because I am entering all the past data. Once it's up to date, I will only be entering one product at a time. Sometimes two. There'd be no reason for this after that, so I can simply remove the AfterUpdate and delete the DefaultValue.

As for the opening and closing, is there a better, more elegant way to get the form blank again after entering all my data for the record? The quickest way I could find was to close the form and re-open it.
 
As for the opening and closing, is there a better, more elegant way to get the form blank again after entering all my data for the record?

Click on the New Record button at the left/bottom of the form, to the far right of the record count?

>*
 
Forgive me for asking, but

If this phase is simply data building, can you trust yourself to enter records directly into the table (or are there multiple tables being updated by that form?) through the Datasheet view? Then you can use Ctrl+" to duplicate the above record's field values.
 
have a look at my suggestion here, using two subforms

I think you will end up with a much nicer application.
 
Last edited:
New record button. Wow. I didn't even think of that being down there. Thank you!

A quick google tells me that when in a form, "CTRL +" also creates a new record, so I'll have to try that this afternoon.

While I could enter directly into tables for some of my forms, (this one is simply a recording of measurements as they are taken), some of the other ones are more complicated. One that is for entering customer complaints and returns can often have several products at once, so the main form is used to input customer details, where they purchased it, etc, and the sub form is used to create records for each product that is returned in a separate table.

I will admit I've entered data directly into tables here and there, and at one point even imported some large chunks of data that we had in an Excel spreadsheet directly into a table to save my fingertips, but on the whole I'd like to avoid it. The more company-wide functionality I can add, the better value Access will have in the eyes of my manager.

Also, everything I've read about Access in my research says that data entry into the table is always a no-no. ^^
 
Also, everything I've read about Access in my research says that data entry into the table is always a no-no. ^^
That is true. If you allow data entry into the table directly, you have no control over what someone may do. If you have data entry through a form, you at least have control in that you have events which can trigger things like validation, stop an update if you don't have the entire record filled out properly, etc.
 
That is true. If you allow data entry into the table directly, you have no control over what someone may do. If you have data entry through a form, you at least have control in that you have events which can trigger things like validation, stop an update if you don't have the entire record filled out properly, etc.

That's something I struggled with even using forms at first. I didn't want a record to be able to be created without a complete data set. Eventually I found that I could make fields in the table "required" or not.

There seem to be a lot of little things I pick up here and there. I've been using Excel and Word 2007 for ages, but only realized after using Access that you can zip through the ribbon tabs using the mouse wheel! It's a huge time saver, to say the least.

Today I realized that in the status bar at the bottom it will give me a one line snippet of what a property does. Until today if I'm unsure if the property is exactly what I'm looking for I've been hitting F1, and then wading through the paragraphs of information there. Had I just looked down, I would have seen "Should default values be retrieved?" for example.

Aside from hopefully enrolling in a course or two in the near future to pick some of this up, I'd like to make a trip to the bookstore soon to pick up a nice thick manual on programming and database building techniques. Can anyone recommend a good one?

I've programmed before in C++ (a few course in college), C# (minimally and recreationally), and HyperTalk (way back in the Apple II days). I definitely enjoy creating and working with code, so I'm excited to start dabbling in Visual Basic. It's always easier to learn a new programming language when you've worked with other ones before, even if the new one is completely and utterly different. It gets you into the thinking in code headspace.
 

Users who are viewing this thread

Back
Top Bottom