how to set Set the DateEntry = No by vba on load event? (1 Viewer)

Allan.Day

Registered User.
Local time
Tomorrow, 03:28
Joined
May 18, 2013
Messages
25
My question is as title

how to set Set the DateEntry = No by vba on load event?

big thanks in advance
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:28
Joined
Aug 30, 2003
Messages
36,124
Try

Me.DataEntry = False

But I'd be more likely to use the argument in OpenForm.
 

Allan.Day

Registered User.
Local time
Tomorrow, 03:28
Joined
May 18, 2013
Messages
25
Try

Me.DataEntry = False

But I'd be more likely to use the argument in OpenForm.

Thanks Paul

iam new comer, so can you explain me what the difference and how to use the argument in openform

thanks fo your great response
 

Allan.Day

Registered User.
Local time
Tomorrow, 03:28
Joined
May 18, 2013
Messages
25
i'd add Paul code suggestion as below :

Forms!EditJournalFrm!DocDate.Locked = True
Forms!EditJournalFrm!KdVoucher.Locked = True
Forms!EditJournalFrm!To.Locked = True
Forms!EditJournalFrm!From.Locked = True
Forms!EditJournalFrm!HeaderNote.Locked = True
Forms!EditJournalFrm!InternalReff.Locked = True
Forms!EditJournalFrm!Source.Locked = True
Forms!EditJournalFrm!Posted.Locked = True
Forms!EditJournalFrm!EditJournalDetail.Locked = True
Forms!EditJournalFrm!EditJournalDetail.DataEntry = False
DoCmd.Requery

but doesnt work? do something wrong?
 

MarvinM

Registered User.
Local time
Today, 13:28
Joined
Nov 26, 2013
Messages
64
Allan,

Data Entry is a form property, not a control property. From your code, it looks like "EditJournalFrm" is your form. On this form, you have controls named DocDate, KdVoucher, To, From, HeaderNote, InternalReff, Source, Posted, and EditJournalDetail. You've locked each of those controls. Am I right so far?

Then you try to set the DataEntry property to False. The problem is, a control doesn't have this property. You can set the DataEntry property of the form to False, but not an individual control.

If you want to prevent data entry in that particular control, try the Enable property.

Also, here's a tip that comes from my bitter experience. Always avoid using Access Reserved Words in naming your fields, controls, forms, etc. It will help preserve your sanity during troubleshooting. Believe me. :banghead:
("TO" and "FROM" are reserved words.) It's okay to use them as part of a name, like To_Date or FromDt. Here's a list:
http://office.microsoft.com/en-us/a...rved-words-and-symbols-HA010030643.aspx?CTT=1
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:28
Joined
Aug 30, 2003
Messages
36,124
Sorry, missed the early reply. My guess is that's a subform, in which case try

Code:
Forms!EditJournalFrm!EditJournalDetail.Form.DataEntry = False
 
Last edited:

MarvinM

Registered User.
Local time
Today, 13:28
Joined
Nov 26, 2013
Messages
64
Paul,

I think you're right. He wouldn't be able to set the DataEntry property on the subform control on the main form. But he would be able to do it on the form contained within that subform control. Very good insight! I didn't think of that. Looking at the names, that must be what it is. I hope Allen gets back to us and let's us know if he got this working.
 

MarvinM

Registered User.
Local time
Today, 13:28
Joined
Nov 26, 2013
Messages
64
-- Off Topic -- :rolleyes:

Thanks, Paul. I've been bitten by reserved words, even recently!
We know that "CurrentUser" is a reserved word. Right? So, I tried using "Current_User". Turns out, that is reserved too! (by the Access database engine)
Had to go with "CurrUser".
 

MarvinM

Registered User.
Local time
Today, 13:28
Joined
Nov 26, 2013
Messages
64
OMG!:eek:

I had no idea! I was using the list from the MSDN website.

I have gotten so much good stuff from Allen's website. I don't need to copy his functions whole, but I do read through them, comparing, to see if he did anything different than mine. I usually find that he's much smarter than me. One thing was a little method he had added to a function that checked for nulls. I hadn't even considered that, so I added it to my code. I need to learn more about error handling too. He has a lot of good examples of that too.

Thanks for pointing me to this list.:)
 

Users who are viewing this thread

Top Bottom