473,385 Members | 1,752 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,385 software developers and data experts.

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

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.
Sep 7 '19 #1
2 1388
twinnyfo
3,653 Expert Mod 2GB
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.
Sep 9 '19 #2
cactusdata
214 Expert 128KB
Always handle date and time as such, not text. Thus:

Expand|Select|Wrap|Line Numbers
  1.     Dim varItem As Variant
  2.  
  3.     Dim i As Integer
  4.     Dim strVal As String 
  5.  
  6.     varItem = Split(txtReaderData, vbCrLf)
  7.  
  8.     For i = 0 To UBound(varItem)
  9.         Select Case Left(varItem(i), 3) 
  10.             Case "DBA"
  11.                 ' Value could be: "20190927"
  12.                 strVal = Format(Mid(varItem(i), 4), "@@@@/@@/@@")
  13.                 Me.DLExp = strVal
  14.                 If IsDate(strVal) Then
  15.                     If DateDiff("d", CDate(strVal), Date) > 0 Then
  16.                         MsgBox "License is Expired" 
  17.                     End If
  18.                 End If
  19.         End Select 
  20.     Next i
Sep 27 '19 #3

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

Similar topics

1
by: PhilM | last post by:
Kindly break out the 4x2 and bring me to my senses. I seem to have gotten myself totally confused with php.net, mysql.org pages on dates etc, as well as groups.google. Could someone explain,...
0
by: Bijoy Naick | last post by:
Hello, MySQL Version = 3.23.46 I am working with a table which has a date field but type is varchar. This cannot be changed. I don't have control over this. I need to run a set of queries...
26
by: sgershon | last post by:
Hi. I know this is should be a simple question. I know server-side web-programming, and never needed to use client-side scripting... until now :) I have done so far a little number of scripts...
0
by: Vijay Balki | last post by:
I am getting the above error message, when I try to download a file from a webserver using SOAP attachments. I read a documentation and it said to do the following on client side so the server will...
8
by: John Wildes | last post by:
Hello all I'm going to try and be brief with my question, please tell me if I have the wrong group. We are querying transaction data from a DB3 database application. The dates are stored as...
1
by: Emilio | last post by:
Question about Dim data As () = System.Text.Encoding.ASCII.GetBytes(message) Would it be the same to write: Dim data() As Byte = System.Text.Encoding.ASCII.GetBytes(message) ?
0
by: Kim | last post by:
Hi, I am working on a web server that clients can upload/download files using WSE2.0 sp3. Files are DIME-attached to a soap message. The web server accepts files without any problem when the files...
8
by: Steve Cartnal | last post by:
I have tried every function that seemed applicable and can't seem to convert a simple text field containing numbers, for example "022807", into a date. Nor can I do the reverse and convert a date...
3
by: Adrian Tache | last post by:
I'm trying to make an accessible form for my users but am having a hard time doing so. I've created all tables with normal PKs (Autonumber) and query-generated ReadableIDs as a very intelligible...
6
by: jdusn1978 | last post by:
Goal: Convert text to date in a query and show only dates that are older than 60 days from Date() I’ve searched the site and nothing quite matches what I’m looking for, at least in a way I can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.