469,356 Members | 1,918 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Set Data Entry = False on form when opening

116 100+
I have created a form and from the main menu I click a button and it opens my form so I can enter new records. The Data Entry is set to true so that i can do this.

I would like to use the same form later in the database to recall my entries and my using the following code I double click on a field (machine) and it should bring up my form which i can view.

Expand|Select|Wrap|Line Numbers
  1. Private Sub machine_DblClick(Cancel As Integer)
  2. Dim gstrwhereid As String
  3.  
  4.     gstrwhereid = "[urn] = " & Me!urn
  5. 'will open form where id matches line clicked
  6.     DoCmd.OpenForm FormName:="frm_timesheet_header", wherecondition:=gstrwhereid
  7.     DoCmd.Close acForm, Me.Name
  8.  
  9. End Sub
  10.  
However I need the form to have DataEntry = False as otherwise I get an empty form. how can i do this. I entered in the code in the above
Expand|Select|Wrap|Line Numbers
  1.  Me.Dataentry = false 
but this did not work.

Any help appreciated.
Thanks
Christine.
Aug 29 '10 #1

✓ answered by TheSmileyCoder

In the code you posted, you do not specify which datamode the form should open in. It will then default to the forms set properties. To override the forms property you can specify a datamode as shown below
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm FormName:="frm_timesheet_header", wherecondition:=gstrwhereid ,datamode:=acFormedit

P.S. Using Me.DateEntry will affect only the form in which it is coded, you cannot use Me. to modify another form. If you want to modify the properties of another form, you could use:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm FormName:="frm_timesheet_header", wherecondition:=gstrwhereid
  2. Forms("frm_timesheet_header").form.DataEntry=False 
In this case its important that the order of the two lines is maintained, as the 2nd line of code only works on a open form.
Note however, that this, will only work if the form being opened is not opened in modal mode (I.e. form keeps focus, thus essentially pausing the code until the form is closed agian. If it is modal, the 2nd line of code would only run, after you have closed frm_timesheet_header".

4 8783
missinglinq
3,532 Expert 2GB
Are you aware that setting Data Entry to Yes is not necessary in order to enter new records?

Data Entry = No
AllowAdditions = Yes
AllowEdits = Yes

will allow the adding of new records and the viewing/editing of existing records.

Linq ;0)>
Aug 29 '10 #2
jacc14
116 100+
hi. I have done this but when I wish to open the form to add a new record I wish it to open as a blank form. It currently brings up the data from the first record in the table.
Thank You
Christine
Aug 30 '10 #3
TheSmileyCoder
2,321 Expert Mod 2GB
In the code you posted, you do not specify which datamode the form should open in. It will then default to the forms set properties. To override the forms property you can specify a datamode as shown below
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm FormName:="frm_timesheet_header", wherecondition:=gstrwhereid ,datamode:=acFormedit

P.S. Using Me.DateEntry will affect only the form in which it is coded, you cannot use Me. to modify another form. If you want to modify the properties of another form, you could use:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm FormName:="frm_timesheet_header", wherecondition:=gstrwhereid
  2. Forms("frm_timesheet_header").form.DataEntry=False 
In this case its important that the order of the two lines is maintained, as the 2nd line of code only works on a open form.
Note however, that this, will only work if the form being opened is not opened in modal mode (I.e. form keeps focus, thus essentially pausing the code until the form is closed agian. If it is modal, the 2nd line of code would only run, after you have closed frm_timesheet_header".
Aug 30 '10 #4
jacc14
116 100+
Thank you very much. works first time.

Best regards Christine.
Aug 30 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Paul Fairless | last post: by
2 posts views Thread by badboybrown | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.