Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening/Closing Forms

Status
Not open for further replies.

cell0042

Programmer
Nov 5, 2002
16
US
I've just created a database for my boss. The problem he had with it was when he opens up a certain form the information from the last time was still in there. So I created a macro that would only let him add records. But now he wants the form to open up with no information filled out but he also wants to be able to view other records at the same time. Is there something that I have to do with the one macro I created?
 
when you call openform you can put a wherecondition in that is impossible, this way no records pop up in the form, but you will automatically be on the new record. I am kind of confused about what the boss wants. If he wants to open the same form 2x, I am not sure if you can do that, but you can create 2 forms for him, a datasheet or continuous form and a single form and let him open both or just one.
 
Check the AllowAdditions, AllowEdits, and DataEntry properties. They can be used in real-time to alter how the form displays.

For example, if you want the form to open "empty", ready for a NEW record to be added, set the DataEntry property to TRUE.

Sub Form_Open()
Me.DataEntry = TRUE
End Sub

In this mode, NEW records may be added, but once they're in, you won't be able to position to them and edit or maintain them. In other words, DATAENTRY means DATA ENTRY ONLY.

If later on, you'd like to display records on the form and allow for scrolling, editing, etc. simply place a button or something that can be clicked on, and code it thusly:

Sub btnMakeFormEditable_Click()
With ME
.DataEntry = false
.AllowEdits = TRUE
.AllowDeletions = TRUE
.Requery
End With
End Sub

There are a couple other of these Allow... guys in the form property sheet, I just don't remember them right now. Check it out.

Jim



Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
On an OnClick event for the button on my main menu that calls up the form I have the following code :

Dim stFormName As String
Dim stLinkCriteria As String

stDocName = "yourformname"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec


I use this to open a form and call a blank record, it may not be the most elegant way but it is simple.

I hope this helps.
Justin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top