Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2012
    Location
    India
    Posts
    42

    Question Unanswered: Update Current date to bound date field

    I'm getting an error in the following line:
    Me.LicLogDt = Date
    I want to update LicLogDt(bound date field) to get current date of system on form load/open, but error says "Can't assign a value". It is working on Form Close but not on Open/Load. Please guide to do so.
    ----------
    Code:
    ----------
    Private Sub Form_Load()
    If Date < Me.LicLogDt Then
    MsgBox ("System date is less than last login date. Please set your system date to current first and login again."), vbInformation, "Error"
    DoCmd.Close
    Else
    Me.LicLogDt = Date
    If Me.LicLogDt >= Me.LicExpDt Then
    MsgBox ("Trail period has been expired. Please purchase full version of Auto Evolution today."), vbCritical, "Demo Expired"
    CurrentDb.Execute "UPDATE tblLicence SET strCheckLicence = 'Validation' WHERE idLicence = 1"
    End If
    End If
    End Sub

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    you need to refer to the actual property in the control not the control. otherwise the runtime tries to assign date to a control

    Me.LicLogDt.value = Date()

    strictly speaking you should always explicitly refer to the property of the object you want to work on / with. but Access/VBA and VB have always had default properties built in fo r ease of use

    fwiw there is also a typo
    MsgBox ("Trail
    probably should read
    MsgBox ("Trial
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2012
    Location
    India
    Posts
    42

    Thumbs down

    Both are same, not working at all.

    please help.

  4. #4
    Join Date
    Jun 2011
    Location
    Inside your mind
    Posts
    297
    Can you post your Database?

    Also, can you encase code in the [ CODE ] ... [ /CODE ] tags on the forums... It's horrible to read the way you have it shown in your original post.
    Looking for the perfect beer...

  5. #5
    Join Date
    Jan 2012
    Location
    India
    Posts
    42

    Lightbulb Re:Update Current date to bound date field

    Thank dear,

    But I got my logic in this way:
    -----------------------------
    Private Sub Form_Load()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset

    Set db = CurrentDb()
    Set rs = db.OpenRecordset("tblLicence")

    If Date < rs!LicLogDt Then
    MsgBox ("System date is less than last login date. Please set your system date to current first and login again."), vbInformation, "Error"
    DoCmd.Quit
    Else
    With rs
    .Edit
    .Fields("LicLogDt") = Date
    .Update
    End With
    If Date >= rs!LicExpDt Then
    MsgBox ("Trail period has been expired. Please purchase full version of Auto Evolution today."), vbCritical, "Demo Expired"
    CurrentDb.Execute "UPDATE tblLicence SET strCheckLicence = 'Validation' WHERE idLicence = 1"
    DoCmd.Quit
    End If
    End If
    End Sub
    ---------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •