473,405 Members | 2,379 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,405 software developers and data experts.

How To Auto-complete a field with a date?

greeni91
Hi All,

I am currently upgrading a problem report I did a little while back and my boss asked if I could:
  • Auto Complete "Completion Date" field with today's date
  • Grey out a select amount of fields for an ECR
  • Lock feedback field when form has been signed off

I have been able to complete the second bulletpoint from the list but I am having trouble writing code for both other bullet points.

Problem 1: Auto Complete "Completion Date" field

I have three 3 fields at the bottom of my form which are linked to a lookup field. These fields return names to the boxes.

What I am trying to do is set up an if statement that will say:

Expand|Select|Wrap|Line Numbers
  1. If Me.QCSignOff.Value > 0 Then
  2.    If Me.ManuSignOff.Value > 0 Then
  3.       If Me.EngSignOff.Value > 0 Then
  4.       Me.CompletionDate.Value = (Today's Date)
  5.       Else
  6.       Me.CompletionDate.Value = ""
  7.       End If
  8.    End If
  9. End If


Problem 3: Lock Feedback field when form has been Signed Off

This problem is directly linked with the problem above, in the fact that I want the Feedback field to disable when QCSignOff, ManuSignOff and EngSignOff have a value entered into their respective fields.

I left this out of the first problem because I want to deal with one of them at a time.


Thanks in advance for the Help...
(Sorry for messiness)

/Sandy
Jan 21 '10 #1
5 3801
Delerna
1,134 Expert 1GB
Your If statement appears to say the correct thing. You didn't say what the problem was.

Your code sample says (Today's Date)
Does this mean you don't know the fuction to get it?

=Now() will set it to todays date and time
=Date() will set it to todays date


As to locking the feedback control
Expand|Select|Wrap|Line Numbers
  1. me.controlname.enabled=false
  2.  
will do that
Jan 21 '10 #2
I am trying to get today's date to automatically fill in the CompletionDate field on my form. The fields QCSignOff, ManuSignOff and EngSignOff are lookup fields in a table that returns names of my bosses when filled in on the form, so I am not sure if the .Value > 0 statements are correct or not.

I have tried tweaking my code abit and nothing seems to work. It doesn't even disable the Feedback field which makes me think that the .Value > 0 statement isn't correct.

I think I may be missing an important piece of code from the code I have written but I can't put my finger on what it is. I thought to start with it was maybe defining a variable at the start of the code, but alas that didn't work either...

When I put the Date() function into my code as Me.CompletionDate.Value = Date(), VBA automatically drops the parenthesis at the end of Date.

I don't know whether it would be better if I wrote this code in Expression Builder...

Any more help is greatly appreciated.

/Sandy
Jan 22 '10 #3
missinglinq
3,532 Expert 2GB
disable when QCSignOff, ManuSignOff and EngSignOff have a value entered into their respective fields.
Your code such as

If Me.QCSignOff.Value > 0 Then

should be

If Not IsNull(Me.QCSignOff) Then

and the same for your other If statements.

Linq ;0)>
Jan 22 '10 #4
I have re-written my code as MissingLinq told me to do but my feedback field will not disable and no date will fill the CompletionDate field. I don't know how to write the code to have the Date() incorporated into it. Every time I try to write it with the parenthesis, VBA drops them at the end of Date.

I don't know whether I have the code in the right procedure, I have written it in the after update for the completion date and I took a dump of the code and pasted it to the form_current event.

My code as current is this, can anybody see something wrong in the code?:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CompletionDate_AfterUpdate()
  2. If Not IsNull(Me.QCSignOff) Then
  3.     If Not IsNull(Me.ManuSignOff) Then
  4.         If Not IsNull(Me.EngSignOff) Then
  5.         Me.Feedback.Enabled = False
  6.         Me.CompletionDate.Value = Date
  7.         Else
  8.         Me.Feedback.Enabled = True
  9.         Me.CompletionDate.Value = " "
  10.         End If
  11.     Else
  12.     End If
  13. Else
  14. End If
  15. End Sub
/Sandy
Jan 25 '10 #5
I played around a little bit with my code this morning and made a few changes to the code provided above.

The problem with the last code was that it was locking the Feedback field when information was in the QCSignOff, ManuSignOff and EngSignOff boxes. The code would not put the current date into the CompletionDate field.

I have proven out this code myself and it seems to work ok. It only does it on the record you are on and once everything has been removed from the boxes mentioned above the date disappears from the CompletionDate field and the Feedback field is unlocked/enabled, it also saves all the information, i.e. You can leave the database and the information remains.

My new code is as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CompletionDate_Enter()
  2. Dim MyDate
  3. MyDate = Date
  4. If Not IsNull(Me.QCSignOff) Then
  5.     If Not IsNull(Me.EngSignOff) Then
  6.         If Not IsNull(Me.ManuSignOff) Then
  7.         Me.CompletionDate.Value = MyDate
  8.         Me.Feedback.Enabled = False
  9.         Else
  10.         Me.CompletionDate.Value = Null
  11.         Me.Feedback.Enabled = True
  12.         End If
  13.     Else
  14.     Me.CompletionDate.Value = Null
  15.     Me.Feedback.Enabled = True
  16.     End If
  17. Else
  18. Me.CompletionDate.Value = Null
  19. Me.Feedback.Enabled = True
  20. End If
  21. End Sub
The way this is set-up is that when all the information has been set in the three boxes, you will need to click on or tab to the CompletionDate box for the code to activate.

I am not entirely sure if you click on the box on another occasion when all the information is complete whether it will add the new date to the CompletionDate field... I will check it out and post back.

/Sandy
Jan 26 '10 #6

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

Similar topics

2
by: Manlio Perillo | last post by:
Hi. This post follows "does python have useless destructors". I'm not an expert, so I hope what I will write is meaningfull and clear. Actually in Python there is no possibility to write code...
1
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the...
5
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge...
20
by: Vijay Kumar R. Zanvar | last post by:
Hello, Unlike register, auto keyword can not be used to declare formal parameter(s). Is there any specific reason for this? Kind regards, Vijay Kumar R. Zanvar
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
5
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the...
5
by: maya | last post by:
at work they decided to center divs thus: body {text-align:center} #content {width: 612px; text-align:left; margin: 0 auto 0 auto; } this works fine in IE & FF, EXCEPT in FF it doesn't work if...
22
by: nospam_news | last post by:
I currently get asked about my usage of "auto". What is it for? The keyword is clearly superflous here. In contrast to the huge majority of C/C++ developers I write definitions very explicitly...
2
by: Piotr K | last post by:
Hi, I've encountered a strange problem with Firefox which I don't have any idea how to resolve. To the point: I've <divelement with a style "height: auto" and I want to retrieve this value...
21
by: JOYCE | last post by:
Look the subject,that's my problem! I hope someone can help me, thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.