By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,816 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,816 IT Pros & Developers. It's quick & easy.

Text converted to date then trigger a message if it has expired

P: 1
I have a form that has an unbound text box set to shortdate, I scan in my data through a pdf417 barcode scanner, I need to convert the 8 digits to a date and then have it entered into the unbound box where it will trigger a message saying the individual term has expire. I do not need to keep the this date once it is shown in the form, My code for reading the barcode is:
Expand|Select|Wrap|Line Numbers
  1. Dim varItem As Variant
  2.     Dim i As Integer
  3.     Dim strVal As String
  4.  
  5.  
  6.  
  7.     varItem = Split(txtReaderData, vbCrLf)
  8.  
  9.     For i = 0 To UBound(varItem)
  10.         strVal = ""
  11.         Select Case Left(varItem(i), 3)
  12.  
  13.         Case "DBA"
  14.         strVal = Mid(varItem(i), 4)
  15.         'If Len(strVal) > 0 Then Me.DLExp = strVal
  16.             Me.DLExp = Mid(varItem(i), 4)
  17.  
  18.  
  19.          If strVal < Date Then
  20.             MsgBox "License is Expired" 
  21.            End If
  22.  
  23.         End Select
  24.  
  25.     Next i
It will put the data into the form but it doesn't see it as a date or as an entry. I have tried to put the If statement in the unbound box before update and also in the after update. It will not show it as a date or as any date in the unbound box unless you change the date in the unbound box. When it debugs it tells me it is mismatched.
1 Week Ago #1
Share this Question
Share on Google+
1 Reply


twinnyfo
Expert Mod 2.5K+
P: 3,278
Dano61,

Welcome to Bytes!

What you will need to do is use the value of strVal that you get in Line 14 and determine if it is a date prior to doing anything else. Then assign that date to the Text Box (you may not need to assign the value to the text box if all you are doing is determining if the license is expired, but htere my be value in displying it).

However, you do not state the format that strVal is in. This will determine how to evaluate strVal as a Date or not. You can use the function cDate(), which accepts a text value and resolves that value to a date, but if the value is not a date, it will throw an error.

Access's universal date format is "YYYY-MM-DD", so, if you are able to somehow manipulate strVal to look like that, and then use cDate(strVal), it should resolve to a date.

Without more information, I can't give any more detailed advice.
1 Week Ago #2

Post your reply

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