469,631 Members | 1,302 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Data Access Pages - adding command buttons & other functionality

579 512MB
Hi everybody,

I've searched and searched for the answers to these questions until I've turned blue in the face, so I finally decided to come here for some assistance.

Here's the info I'm working with:
MS Access 2003
Call log database using data access pages
One table called tblCRS_Data_Log
Primary key is CallNo
An assortment of other fields, including check, text, and combo boxes
There are other tables that supply the info for the combo boxes
I'm trying to make this functional for my least computer saavy employees. The main thing I'm trying to accomplish is to be able to add some similar functionality to the data access pages as I would to a regular form.

In particular, I have a separate date field and time field. I would like to add a today and yesterday command button to input the date for the date field and a current command button to input the current time. Those are the two most important aspects.

The other thing I would like to accomplish, if possible, but not entirely necessary, is to be able to add functionality to a checkbox so that it will enable a text field and change the fore color of the corresponding label red when the value of the checkbox is true.

I have some experience with javascript (in fact, I have a today and yesterday function written) and I've stumbled through a little vbscript before, but my problem is implementing it using the data access page. That is something that has completely thrown me for a loop.

If you can help me with this, and the sooner the better, I would greatly appreciate it. Thanks in advance...
Jul 29 '08 #1
2 2731
579 512MB
I figured out the first part of my problem and I will post it here for anyone that might find it useful.

To add a command button that will input the date into a text field, draw the command on your data access page (DAP) and then go to the Microsoft Script Editor. Change to "Script Only View" and open your "Document Outline" toolbar.

Find the name of your command button in the "Document Outline" list and expand the sublist. Double click the "onclick" event and a new script tag will appear in the editor.

For me, I just want to add a button for today's date and another button for yesterday's date. Here's what I typed in between the script tags:

Expand|Select|Wrap|Line Numbers
  2. ''''''''''''''''''''''''''''''''''''''''''''
  3. ' Today's date
  4. ''''''''''''''''''''''''''''''''''''''''''''
  6. <SCRIPT language=vbscript event=onclick for=cmdToday>
  8.     dim myDateT                    'declare variable for the date to be stored
  10.     myDateT = Date()            'set the variable equal to today's date
  12.     DateField.value = myDateT    'make the textbox equal to the value stored in the variable
  14. </SCRIPT>
  16. '''''''''''''''''''''''''''''''''''''''''''''''''''''''
  17. ' Yesterday's date
  18. '''''''''''''''''''''''''''''''''''''''''''''''''''''''
  20. <SCRIPT language=vbscript event=onclick for=cmdYesterday>
  21. <!--
  23.     dim myDateY                    'declare variable for the date to be stored
  25.     myDateY = Date()-1            'set the variable equal to yesterday's date
  27.     DateField.value = myDateY    'make the textbox equal to the value stored in the variable
  29. -->
  30. </SCRIPT>
Here's another script if you want to input a time in hh/mm AM/PM format (Thanks to http://www.ronshardwebapps.com for the code. Be sure to check out the site for complete details and further instruction):

Expand|Select|Wrap|Line Numbers
  2. ''''''''''''''''''''''''''''''''''''''''''
  3. ' Current time
  4. ''''''''''''''''''''''''''''''''''''''''''
  6. <SCRIPT language=vbscript event=onclick for=cmdCurrent>
  7. <!--
  8.                 dim temp, myTime, myAMPM, myColon, myHour, myMinute
  10.     temp = FormatDateTime(Time(), vbLongTime)
  12.     myAMPM = Right(temp, 2)
  14.     myColon = instr(1, temp, ":", vbBinaryCompare)
  15.     if myColon = 2 then
  16.         myHour = Left(temp, 1)
  17.         myMinute = Mid(temp, 3, 2)
  18.     else
  19.         myHour = Left(temp, 2)
  20.         myMinute = Mid(temp, 4, 2)
  21.     end if
  23.     myTime = myHour & ":" & myMinute & " " & myAMPM
  25.     TimeField.value = myTime
  27. -->
  28. </SCRIPT>
Please Help !

I'm still having trouble with one part. I have a textbox that, when clicked, I want to be able to enable 2 other textboxes and change the label color red. If anyone can help me out with that I would really appreciate it.

It's easy to do with VBA in Access, but these DAPs seem to be a different animal.

Jul 30 '08 #2
579 512MB
Ok...my post can be closed. I finally got everything to work.

If you want a label to be changed when the state of a checkbox is changed, you have to use the following:

Expand|Select|Wrap|Line Numbers
  2. labelName.style.color = "red"
Initially I was using the RGB(red, green, blue) function on the other side of the equal sign and when I entered (255,0,0) for red, for some reason, the color was changing to blue. Still can't figure that one out...maybe I needed to put it in quotes? Oh well, I'm good to go now...
Jul 30 '08 #3

Post your reply

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

Similar topics

16 posts views Thread by D Witherspoon | last post: by
32 posts views Thread by Neil Ginsberg | last post: by
6 posts views Thread by Peter Frost | last post: by
42 posts views Thread by lauren quantrell | last post: by
3 posts views Thread by Lyle Fairfield | last post: by
3 posts views Thread by RAR in WA | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.