Results 1 to 4 of 4
  1. #1
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80

    If statement comparing 2 values

    I honestly do not know why this code is not working, but any ideas would be appreciated. The code should check if access is currently blocked, which it does fine. Then it should check if the current front end version is lower than the back end version, and if it is lower it should prompt that a new version be downloaded. The problem is no matter what the value of the front end version is, lower, equal, or higher, it always prompts to download a new version. On the opening form there are 2 text boxes, one with the current version of the front end which I enter, and one with the back-end version which uses a control source to the linked back-end database to pull the data. In Form View, both fields display 1.35, yet when opening it still prompts to download a new version.



    Code:
    If Me.BlockAccessCheck = True Then
        Me.Visible = False
        DoCmd.OpenForm "frmBlockAccess"
        Forms!frmBlockAccess.SetFocus
    End If
    If Me.VersionTxt < Me.CurrentVersionTxt Then
        VersionResponse = MsgBox("The database has been updated, please retrieve a new copy." & vbCrLf & "Would you like to retrieve a new copy of the database now?", vbYesNo, "Database Out of Date")
            If VersionResponse = vbYes Then
                objShell.Run ("website")
                DoCmd.CloseDatabase
            Else
                'DoCmd.CloseDatabase
            End If
        
    End If

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,463
    Maybe try Val function:
    If Val(Me.VersionTxt) < Val(Me.CurrentVersionTxt) Then

    or test if not equal <> instead of <

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    or try using a trim statement

    if trim(me.versiontxt) <> trim(me.currentversiontxt) then

  4. #4
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80
    Great, worked with both options. Thanks!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-16-2016, 03:10 PM
  2. Replies: 1
    Last Post: 11-11-2015, 04:25 PM
  3. Comparing positive to negative values.
    By rubberducky in forum Access
    Replies: 1
    Last Post: 01-20-2014, 04:44 PM
  4. Replies: 2
    Last Post: 10-29-2012, 11:28 AM
  5. iif statement comparing two fields
    By unslog in forum Access
    Replies: 6
    Last Post: 09-28-2012, 02:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums