Dates in forms

onlyty

Registered User.
Local time
Today, 18:42
Joined
Jul 22, 2008
Messages
45
Hi I am an extremely new newbie and I have started my first proper database. I have a hundred and one questions but to start me off can you please help - I have a field that will complete todays date if the check box(Paid) is ticked but the date doesnt show on the related table.
 
Add the following to the Before Update event of the Paid checkbox

Me.NameofPaidField = Date

HTH
 
Thanks just tried quickly but can you tell me what "me" stands for - going home now but am inspired to continue this duanting task! (I think)
 
Hi,

"Me" refers to the current object you are in such as a form or control. In your example it is refering to the form in which you have the date field.
 
Me, the objective first person singular pronoun in English, see I (pronoun)...
Wait, Max is right... :)
 
Error report

Hi

Thanks for that but still havent got it quite right cos I have the following error

Microsoft Office cant find the macro 'Me' -
 
NEVER EVER EVER use macro's if you want to do anything part way serious in Access.

Macro's are there for the devil's worshipping !!!

Dont click on the "Macro builder" but on the "Code builder" and add the code there.
 
still failing badly

(although I know nothing about these codes) I added the code 'Me.Date_Enrolled = Date' in the code builder for the tick box but when I tried to use it a run time error '2147352567(80020009) - you cant assign a value to this object appeared.

maybe this will give you a better picture:

On my subform I have a tick box for [Paid], and then a [Date Enrolled]=IIf([Paid]<>0,Now(),"").

the Enrolled Students table has a field [Date Enrolled] which is not storing the date details.

also can this date be made stable as I dont want the date to change after it has been inserted.
 
Dont use spaces in column names this prevents a lot of problems.

If you tried to assign the date to "Date_Enrolled" and you column is actually called "Date enrolled" that will be your problem.

Also your default value is useless, as it only works the first time as you have noticed.
 
really think I am losing the plot now

I clicked on the Tick box and enterd the code as 'Me.Enrolled_date = Date' (field name changed - Thankyou but no luck.

I am worried now that maybe the set up is all wrong

I have three tables

students
courses
enrolled students - which I am using as the junction table.

I want to create a form that allows the staff to look for students and book them onto the relevant courses.

the date field will help to match up the enrolled dates - which will taken as the date the student has paid. should I not worry about the [enrolled table] and just use the query instead?

really grateful for your help - my sanity is at stake here. I have done an access course but nothing helped with the initial set up!
 

Attachments

(although I know nothing about these codes) I added the code 'Me.Date_Enrolled = Date' in the code builder for the tick box but when I tried to use it a run time error '2147352567(80020009) - you cant assign a value to this object appeared.
Syntax is wrong. The date function requires empty brackets the same as Now(). So should be Date().

On my subform I have a tick box for [Paid], and then a [Date Enrolled]=IIf([Paid]<>0,Now(),"").

the Enrolled Students table has a field [Date Enrolled] which is not storing the date details.

also can this date be made stable as I dont want the date to change after it has been inserted.
The Access form wizard annoys the hell out of me since it gives the controls it creates the same name as the fields they are bound to. This is bad practice and may be causing you a problem. Change your control name to txtDateEnrolled. Then 2 questions:
Is your control bound the the field?
Which event do you have this code in?
 
Ah, you have as your control source that =IIF formula... That is your problem.

That should be bound to Date_enrolled, once changed it works.
To do this change the "Control source" in the table "Data" from your =IIF to Date_Enrolled.

@Neil
Date in SQL needs () but in VBA it doesnt, nice and consistant I know... *sigh*
 
Tara! - job one complete!

I am a little worried about my set up because there will be a lot more information and tables linked to these Student and courses tables when I build on it - did it seem ok to you is it ok to have the enrolled students as the junction table?

Is there anywhere I can go to look at good set up practice ie underscores not gaps in table headings, better practice field names etc

I thought maybe same prefix for table names, field names etc?
 
I didnt study the design at all... just make sure to always have 1 - N relationships and not get M - N relations...

No underscores, no spaces, no special characters in any name anywhere anytime!

Do use prefixes, most are self explaining.
Some prefixes
tbl, qry, frm, rpt, mod
txt, int, dbl, bln

Indent your coding properly and never use default names for controls, formnames or query names.

Good Luck!
 

Users who are viewing this thread

Back
Top Bottom