473,383 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 9379
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,322 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

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

Similar topics

1
by: Paul Fairless | last post by:
I have a form called frmCustSearch to search for customers against an SQL Server database. The form contains a simple textbox into which the Customers surname is typed, and a datagrid then...
3
by: Carmela | last post by:
Hello Readers, I am trying to update data on a form that is based on a query having a many-to-one-to-many relationship. I found this exciting link that seemed to have the solution for me: ...
4
by: MLH | last post by:
On a data entry only form. lets say a user opens your form and enters 4 consecutive records. Each time, he clicks your SAVE button and a record is save and the record set is advanced to a newrec. ...
4
by: Robert | last post by:
Have main form with an unbound subform1 which is used for data entry. Subform1 has a nested continuous unbound subform (subform2) which is used to enter multiple records related to the record being...
2
by: badboybrown | last post by:
Good afternoon, Please can someone tell me the best way of calling up a form that will allow the user to only add new records. I have other forms that will be used to view the existing...
1
by: lesperancer | last post by:
I've got a form that is opened in readonly mode and no fields can be changed, great but if I click on a combo box that has an _enter() event that sets a field on my form to a value (albeit the...
1
by: BlackFireNova | last post by:
I'm using Access 2003, on Windows XP Pro. I have a subform which is launched from a command button on my main form. When this form opens, I have 2 fields which I have inserted VBA Code into to...
3
by: Matrix34 | last post by:
This will be very simple basic coding to most of you, I'm just experimenting at the moment. I have created a form which I need to popup whenever my excel spreadsheet opens. Could someone...
3
by: rryan2 | last post by:
I am new to this programming stuff, first off, im trying to figure out how to have your initial form close once the user opens the second form. so far all i have is form.show, but that just opens a...
3
by: martin DH | last post by:
I would definitely appreciate any help with this problem as soon as possible. Thanks! I have a report that should display the results of a query based on two tables (tblClient and tblResult,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.