Always open form with the new record

mcdhappy80

Registered User.
Local time
Today, 15:14
Joined
Jun 22, 2009
Messages
347
I've created button on my main form which will will open another form where I will add a record and then move back to main form.
I want to do this when the add record form opens:

1) Always Open blank record;
2) Not be able to move trough records of the forms data source;
3) Only be able to ADD ONE new record;
4) Not to be able to edit records on that form.

What here needs to be done by tweaking forms properties and what with VBA code to make this as I planned?

Thank You.
 
If the DataEntry property is true, you can *only* look at new records. Stopping them from adding a 2nd new record is a different story and depends on a number of factors. Have you locked down the db? Did you turn off the NavButtons?
 
If the DataEntry property is true, you can *only* look at new records. Stopping them from adding a 2nd new record is a different story and depends on a number of factors. Have you locked down the db? Did you turn off the NavButtons?

I've noticed that If I open the form from VBA with the accFormAdd property the form it opens on the new blank record and from there I can add as many records as I want but it doesn't return to the previous added records.

I don't think I've locked the database, how do I do that, and why would I want to do that?
The Navigation is on for now.

The First thing I want to be able to do for now is to know how to return on the record I was on the first form, after I solve that problem I will deal with this problem of being able to add only one record.

Thank You
 
If you use the Dialog argument of the OpenForm, The code in the first foem stops until you close the 2nd form or make it InVisible.
 
If you use the Dialog argument of the OpenForm, The code in the first foem stops until you close the 2nd form or make it InVisible.

So You suggest that I don't close the first form when opening the second, but to open the second in dialog mode whilst the first remains open, and when I close the second I will remain on the same records?

If this is what You're suggesting is there I way to do this but with closing and reopening the first form?

Thank You
 
You do know that you can make the 1st form invisible and then open the 2nd form and when the code gets back make your 1st form visible again right?
 
You do know that you can make the 1st form invisible and then open the 2nd form and when the code gets back make your 1st form visible again right?

Nope I didn't knew that :D
I tried the method without closing and reopening forms and with that method I have the problem that now I need to requery the first form and return on the record I was when I was on the first form.
I need to requery beacuse on the first form I have a combo box which stores values that I'm adding with the second form, so when I switch back from second form to first the combobox must be updated with new records.
So anyway You put it I need to remember on which record I was to return to it after a requery, but there is a matter of two forms here.
I've found some code on internet http://www.baldyweb.com/Requery.htm but as I can see in this example this works as is if I don't switch between forms.
How do I make this work even if I am switching between forms?
Do I need to pass variable (the PK of the record from the first form) between these two forms in order to remember "where I was" so I could now "where to return"?
=====================
I've found other tutorial online http://allenbrowne.com/ser-18.html that looks like pretty much what I'm looking for, I only have one question regarding it, can I, instead of storing PK value in table, store it in Global Variable or in Forms Class Modules variable and pass it between two forms?
Can someone write down how?

Thank You.
 
Last edited:
You can Requery a ComboBox without Requerying the entire form. Me.cboName.Requery using your cboName of course.
 
You can Requery a ComboBox without Requerying the entire form. Me.cboName.Requery using your cboName of course.
Thanks that requery methd works :D
Where would You put Me.cboName.Requery code, in the first forms On Load event or in the second forms On Unload event? I've put it in the seconds form On Unload event and it works, but I'm asking just for reference.

Let me ask You this.
I've successfully passed argument from one form to another, but how do I return that same value to the first form when the second closes?

Thank You.
 
Are you just trying to add to a cbo when the user types something in? Have you looked at the NotInList event?
 
Are you just trying to add to a cbo when the user types something in? Have you looked at the NotInList event?
I've looked at this event as You suggested.
No, I was trying to add a record to second table from second form, and the combo box on the first form displays those records and lets user selects them (not all of them, lets say that combo holds name of user).
Now, when I solved my first problem, any ideas how to solve that "adding just ONE record" problem, because I don't have a clue how would I do that?

Thank You
 
Is it a form that is just used for this 1st form or do you use it for other purposes?
 
You can use the AfterUpdate event of the form to close the form.
 
You can use the AfterUpdate event of the form to close the form.
Yep, that did the trick, thanks ;)
One more question regarding this:
If I set Data Entry property to Yes should I turn off the Allow Additions property (I've turned off Allow Edits and Allow Editions properties)?

Thanks
 
I don't think DataEntry will work without AllowAdditions.
 

Users who are viewing this thread

Back
Top Bottom