ChHange form datamode with VBA

briancross

New member
Local time
Today, 10:31
Joined
Sep 1, 2009
Messages
7
I have a form that I need to have open blank. From what I have read, the best way to do this is to set the data entry property of the form to Yes. However, on this form I have other controls that allow the user to filter and select individual records. The form fails at this point, presumably as a result of the datamode.

Is there a way to change the datamode of the entire form to Edit at runtime when the user selects a record to display?
 
I wouldn't use the DatatEntry Property. Instead I'd use this code:
Code:
Private Sub Form_Load()
 DoCmd.GoToRecord , , acNewRec
End Sub
When the form open it moves you to a new, blank record. You can then do anything you want; add a record, edit a record, search for a record and so forth, without having any user intervention.
 
if you want to enter and select specific records, base the form on a query that returns a single record

then just have a combo box or text box to enter the record data required, and refresh the query. you can even neatly just show the header bit, and hide the detail section while it is empty by using runcommand.accmdsizetofit - i think thats the correct one offhand.

i use this for example in a situation where depot staff have to enter and validate orders individually.
 
John's solution was what I was looking for. Thank you!!!

I was using code to set DataEntry, but it gave me the same problem that setting the property was giving me.
 

Users who are viewing this thread

Back
Top Bottom