Using checkbox to place today'sa date

F

Frank Situmorang

I am new in this disussion group and new in developping access, but I found
it this dissussion is very helpful to me in solving problem. My question is
how can we use check box in one field, if we tick will place to days date in
the "Date Slected" calculated field in my query. This is the calculated query:
DateSelect: IIf([Select]=True,Date(),"")
It works when I tried to tick it, but, I want to hold the date. I found it,
if I tick to morrow the other records, all the selected ones become the same
date which is to day'date, while I want to hold it in order to know the
historical date.

If anyone can help me on this wheter we need to write VB in the form

Thanks & Regards,

FS
 
D

Douglas J. Steele

You need to write VBA on the form, specifically in the BeforeUpdate event to
assign the value to the field in the table.
 
F

Frank Situmorang

Thanks Doug for your explanation, we appreciate if you could give me more
explanation, coz in my case I do not have table for "selected date" it is a
calculated field in my grid query. but I want the original date showed up in
the form every time I browse the records.

Moreover could you inform me where can I find the website explaining and
giving example of the VB language?. I took short course ( just 2 weeks) 30
years ago which I have forgot now.

I am a selft study, my experience in fact is Finance & Accounting and now I
started to refresh my mind by trying to make a program for tracking supplier
invoices, and it is almost finished except that selection of invoice to be
paid is just showing the to day's date all the time. Life is very hard in
Jakarta, Indoensia so we tried to do it ourselves, and I will let my clercks
use this access program

Thanks,

Frank

Douglas J. Steele said:
You need to write VBA on the form, specifically in the BeforeUpdate event to
assign the value to the field in the table.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Frank Situmorang said:
I am new in this disussion group and new in developping access, but I found
it this dissussion is very helpful to me in solving problem. My question
is
how can we use check box in one field, if we tick will place to days date
in
the "Date Slected" calculated field in my query. This is the calculated
query:
DateSelect: IIf([Select]=True,Date(),"")
It works when I tried to tick it, but, I want to hold the date. I found
it,
if I tick to morrow the other records, all the selected ones become the
same
date which is to day'date, while I want to hold it in order to know the
historical date.

If anyone can help me on this wheter we need to write VB in the form

Thanks & Regards,

FS
 
A

AccessVandal via AccessMonster.com

Hi Frank,

Be aware that the code below will always show the current date when the user
check and uncheck and than check again. You’ll need to idiot proof your form
to prevent unwanted changes.

DateSelect: IIf([Select]=True,Date(),"")

Assuming “DateSelect†= Textbox and “Select†= Checkbox is the control names
you have create that form.

First, what you need to do is to create a new field/column in your table and
name it like “DateSelectâ€.

Second, you need to include the new field/column in the Form’s Record Source
as well. (Your query grid)

Next, go to the design mode of the form and go to the control name
“DateSelectâ€, in the properties of the control, set the “Control Source†=
DateSelect. This is the new field/column you have just created.

In the checkbox control, use the OnClick event to populate the Textbox.
It’s on the control properties tab called “Eventâ€, on the Event Tab, just
look for “On Clickâ€, click on the field and on the right of that field, there
is a Combobox arrow, click and select “[Event Procedure]â€. Beside the
ComboBox, click the button “…†to view the VB editor.

This is the event we want to use.
Again assuming “Select†is the checkbox control name.

Private Sub Select_Click()
If IsNull(Me.DateSelect) Then
Me.DateSelect = Date() ‘input current date
End If
End Sub


And to idiot proof the checkbox. Use the Form’s current event.

Private Sub Form_Current()
If Not IsNull(Me.DateSelect) Then
Me.Select.Enable = False ‘disable the control
Else
Me.Select.Enable = True ‘enable the control
End If
End Sub

The above are only sample and not a complete solution. Get an Access
developer if you need a complete solution and security to prevent unwanted
changes (if you can afford one)
 
D

Douglas J. Steele

It's not possible. If you want the date to "stick", you must store it in the
table.

Check out "The Access Web" http://www.mvps.org/access/ for examples of VBA
coding, and links to other sites. (Note that it's VBA - Visual Basic for
Applications - not VB, although there aren't many syntactical differences)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Frank Situmorang said:
Thanks Doug for your explanation, we appreciate if you could give me more
explanation, coz in my case I do not have table for "selected date" it is
a
calculated field in my grid query. but I want the original date showed up
in
the form every time I browse the records.

Moreover could you inform me where can I find the website explaining and
giving example of the VB language?. I took short course ( just 2 weeks) 30
years ago which I have forgot now.

I am a selft study, my experience in fact is Finance & Accounting and now
I
started to refresh my mind by trying to make a program for tracking
supplier
invoices, and it is almost finished except that selection of invoice to be
paid is just showing the to day's date all the time. Life is very hard in
Jakarta, Indoensia so we tried to do it ourselves, and I will let my
clercks
use this access program

Thanks,

Frank

Douglas J. Steele said:
You need to write VBA on the form, specifically in the BeforeUpdate event
to
assign the value to the field in the table.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Frank Situmorang said:
I am new in this disussion group and new in developping access, but I
found
it this dissussion is very helpful to me in solving problem. My
question
is
how can we use check box in one field, if we tick will place to days
date
in
the "Date Slected" calculated field in my query. This is the calculated
query:
DateSelect: IIf([Select]=True,Date(),"")
It works when I tried to tick it, but, I want to hold the date. I found
it,
if I tick to morrow the other records, all the selected ones become the
same
date which is to day'date, while I want to hold it in order to know the
historical date.

If anyone can help me on this wheter we need to write VB in the form

Thanks & Regards,

FS
 
F

Frank Situmorang

Thank you Doug for your explanantion, this is a great help for me

Frank

Douglas J. Steele said:
It's not possible. If you want the date to "stick", you must store it in the
table.

Check out "The Access Web" http://www.mvps.org/access/ for examples of VBA
coding, and links to other sites. (Note that it's VBA - Visual Basic for
Applications - not VB, although there aren't many syntactical differences)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Frank Situmorang said:
Thanks Doug for your explanation, we appreciate if you could give me more
explanation, coz in my case I do not have table for "selected date" it is
a
calculated field in my grid query. but I want the original date showed up
in
the form every time I browse the records.

Moreover could you inform me where can I find the website explaining and
giving example of the VB language?. I took short course ( just 2 weeks) 30
years ago which I have forgot now.

I am a selft study, my experience in fact is Finance & Accounting and now
I
started to refresh my mind by trying to make a program for tracking
supplier
invoices, and it is almost finished except that selection of invoice to be
paid is just showing the to day's date all the time. Life is very hard in
Jakarta, Indoensia so we tried to do it ourselves, and I will let my
clercks
use this access program

Thanks,

Frank

Douglas J. Steele said:
You need to write VBA on the form, specifically in the BeforeUpdate event
to
assign the value to the field in the table.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I am new in this disussion group and new in developping access, but I
found
it this dissussion is very helpful to me in solving problem. My
question
is
how can we use check box in one field, if we tick will place to days
date
in
the "Date Slected" calculated field in my query. This is the calculated
query:
DateSelect: IIf([Select]=True,Date(),"")
It works when I tried to tick it, but, I want to hold the date. I found
it,
if I tick to morrow the other records, all the selected ones become the
same
date which is to day'date, while I want to hold it in order to know the
historical date.

If anyone can help me on this wheter we need to write VB in the form

Thanks & Regards,

FS
 
F

Frank Situmorang

I have tried your suggestion Vandals, but error messages says " Compiled
Error: Method or data member is not found"
Could you give me more explanation.

Moreover, where can we find all the explanantion of this function like Me.
etc, I tried to find it("Me") on the Access Help, but I could not find. In
the Northwind sample it is stated like "Me!Shipaddress=Me!customershipment"

Thanks very much,

Frank
Jakarta, Indonesia

AccessVandal via AccessMonster.com said:
Hi Frank,

Be aware that the code below will always show the current date when the user
check and uncheck and than check again. You’ll need to idiot proof your form
to prevent unwanted changes.

DateSelect: IIf([Select]=True,Date(),"")

Assuming “DateSelect†= Textbox and “Select†= Checkbox is the control names
you have create that form.

First, what you need to do is to create a new field/column in your table and
name it like “DateSelectâ€.

Second, you need to include the new field/column in the Form’s Record Source
as well. (Your query grid)

Next, go to the design mode of the form and go to the control name
“DateSelectâ€, in the properties of the control, set the “Control Source†=
DateSelect. This is the new field/column you have just created.

In the checkbox control, use the OnClick event to populate the Textbox.
It’s on the control properties tab called “Eventâ€, on the Event Tab, just
look for “On Clickâ€, click on the field and on the right of that field, there
is a Combobox arrow, click and select “[Event Procedure]â€. Beside the
ComboBox, click the button “…†to view the VB editor.

This is the event we want to use.
Again assuming “Select†is the checkbox control name.

Private Sub Select_Click()
If IsNull(Me.DateSelect) Then
Me.DateSelect = Date() ‘input current date
End If
End Sub


And to idiot proof the checkbox. Use the Form’s current event.

Private Sub Form_Current()
If Not IsNull(Me.DateSelect) Then
Me.Select.Enable = False ‘disable the control
Else
Me.Select.Enable = True ‘enable the control
End If
End Sub

The above are only sample and not a complete solution. Get an Access
developer if you need a complete solution and security to prevent unwanted
changes (if you can afford one)
Frank Situmorang wrote:
Thanks Doug for your explanation, we appreciate if you could give me more
 
A

AccessVandal via AccessMonster.com

Hi Frank,
I have tried your suggestion Vandals, but error messages says " Compiled
Error: Method or data member is not found"
Could you give me more explanation.

It means that the control does not exist or is misnamed. For example, if you
have a control/textbox/combobox on a form and the control, say we name it
“Select Date†but in the “event procedure†you name it as “Selectâ€. So, in
this case you’ll have to correct the misnamed control in the VB editor.

Notice that if you leave a space when you name a control, you must use the
Bang instead of the Dot like “Me![Select Date]†or “Me.Select_Date†(later on
this underscore). You use Bang with the square brackets when you name a
control or you use the Record Source with query or Table with a Field/Column
name with a space.

When you use the Dot, a combobox like VB intellisense will appear with the
methods and properties. Most importantly, what you want is the control name
which you want to look for, example, if you name the control “Selectâ€, than
when you key in “Me.†with the dot, and key in the control name first letter
“Sâ€, the control name will appear on the intellisense list.

In Access, we name controls for a textbox is “txtSelect†and combobox is
“cboSelectâ€. If you leave a space when naming controls for example “Select
Dateâ€, by default Access will name it to “Select_Date†with the underscore
added between the spaces.
Moreover, where can we find all the explanantion of this function like Me.
etc, I tried to find it("Me") on the Access Help, but I could not find. In
the Northwind sample it is stated like >"Me!Shipaddress=Me!customershipment"

“Me†refers to the Form’s properties, methods and controls. You can only use
“Me†in the Form’s module. Example, “Me.Dirty†if it’s True, the record was
edited. “Dirty†is one of the form’s properties. “Me.ControlName.Propertiesâ€
refers to the control properties.

There’s no harm using the Bang, but you’ll have to key in the correct name
and if it is 20 charactors or more, you’ll have to key in 20 times. But with
Dot, you just key the search character or second than press the space bar to
select the correct name.
 
F

Frank Situmorang

Hi Vandals,
Nothing wrong with the name of the control, the name of the control in the
form is "ToBePaid" and the control source is "select" which will take from
the query grid.

But the problem still persist, please help if you have any idea.


AccessVandal via AccessMonster.com said:
Hi Frank,
I have tried your suggestion Vandals, but error messages says " Compiled
Error: Method or data member is not found"
Could you give me more explanation.

It means that the control does not exist or is misnamed. For example, if you
have a control/textbox/combobox on a form and the control, say we name it
“Select Date†but in the “event procedure†you name it as “Selectâ€. So, in
this case you’ll have to correct the misnamed control in the VB editor.

Notice that if you leave a space when you name a control, you must use the
Bang instead of the Dot like “Me![Select Date]†or “Me.Select_Date†(later on
this underscore). You use Bang with the square brackets when you name a
control or you use the Record Source with query or Table with a Field/Column
name with a space.

When you use the Dot, a combobox like VB intellisense will appear with the
methods and properties. Most importantly, what you want is the control name
which you want to look for, example, if you name the control “Selectâ€, than
when you key in “Me.†with the dot, and key in the control name first letter
“Sâ€, the control name will appear on the intellisense list.

In Access, we name controls for a textbox is “txtSelect†and combobox is
“cboSelectâ€. If you leave a space when naming controls for example “Select
Dateâ€, by default Access will name it to “Select_Date†with the underscore
added between the spaces.
Moreover, where can we find all the explanantion of this function like Me.
etc, I tried to find it("Me") on the Access Help, but I could not find. In
the Northwind sample it is stated like >"Me!Shipaddress=Me!customershipment"

“Me†refers to the Form’s properties, methods and controls. You can only use
“Me†in the Form’s module. Example, “Me.Dirty†if it’s True, the record was
edited. “Dirty†is one of the form’s properties. “Me.ControlName.Propertiesâ€
refers to the control properties.

There’s no harm using the Bang, but you’ll have to key in the correct name
and if it is 20 charactors or more, you’ll have to key in 20 times. But with
Dot, you just key the search character or second than press the space bar to
select the correct name.
Frank Situmorang wrote:
 
A

AccessVandal via AccessMonster.com

hi Frank,

Where did the error point to? i'm sure VB highlighted in blue of a control or
variable some the that code. If possible show the complete code.
 
F

Frank Situmorang

Thanks Vandal for all your explanantions, I found out that the problem is not
in the name of the control, but the command" enable" should have been
"enabled". I am not an English speaker, so, I am not so prudent on this

Again, thank you verymuch
 
A

AccessVandal via AccessMonster.com

Hi Frank,

Part of learning process, good to know you have learn how to use VB.
 
Top