Results 1 to 3 of 3
  1. #1
    webisti is offline The Wisher
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    115

    opening a form when condition is met

    Hi
    I am trying this:
    When user opens a db he goes through a splash form
    the form checks whether the data has been downloaded on the table Orders and if the user is logged into the db on the table Users


    on the table Orders is looking at the date where it should be only today`s date (date() ).
    I want to make it so that:
    If the date in the Orders table is today, and there is a user (or more) logged then go directly to the main form called MAIN, otherwise
    go to form Input.
    I tried this code but is not working proberly:
    Code:
    Private Sub Form_Timer()
    Dim rstdownloader As DAO.Recordset
    Dim rstdone As DAO.Recordset
    Set rstdownloader = CurrentDb.OpenRecordset("SELECT First(User.LogOnDate) AS LOGIN FROM User")
    Set rstdone = CurrentDb.OpenRecordset("SELECT last(Orders.DATE) AS done FROM Orders")
    If rstdownloader.RecordCount > 0 And rstdone Is Date Then
        DoCmd.OpenForm "Main"
    Else
    'DoCmd.OpenForm "input"
    'On the forms timer event close the start-up form
    'Open up the main switchboard form when the start-up form closes
    'End If
     
    DoCmd.Close acForm, "Splash"
    End Sub
    another version I tried:
    Code:
    If IsNull(Me.USER_GLOBAL) Or Me.EBAN_CHECK = "Date()" Then
                MsgBox "DOWNLOAD HAS BEEN DONE", vbOKOnly, "IMFORMATION"
                DoCmd.OpenForm "M_FORM"
            Exit Sub
        End If
    but none is working

    any ideas?

    Thanks a lot

    Webisti

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why doesn't it work, what happens - message box, wrong results, nothing? Have you step debugged? Did you even run Debug > Compile?

    Every module should have Option Explicit in its header. Then every variable should be explicitly declared. Option Explicit will mandate they be.

    Should probably use Max and Min instead of Last and First. Last and First will often not provide desired results.

    Don't put Date() within quote marks.

    IsDate(rstdone!Date)

    Date is a reserved word. Should not use reserved words as field names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    webisti is offline The Wisher
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    115
    Hi june7

    Thanks for your input..with isdate(rstdone!date) it did not worked out but then I realized thanks to your answer that could use the same logic as min max
    therefore I changed it to :
    Code:
     ... rstdone.RecordCount > 0 Then ...
    it worked.

    thanks again.

    Webisti

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

Similar Threads

  1. IF condition in a Macro on my form
    By Steven.Allman in forum Macros
    Replies: 1
    Last Post: 08-02-2013, 06:04 AM
  2. If Statement Condition - Opening Report
    By geraldk in forum Reports
    Replies: 3
    Last Post: 07-10-2013, 10:26 AM
  3. where condition with Navigation form
    By hyman in forum Forms
    Replies: 0
    Last Post: 10-31-2012, 02:39 AM
  4. Replies: 5
    Last Post: 08-13-2010, 07:26 PM
  5. Where Condition - form error
    By catat in forum Forms
    Replies: 5
    Last Post: 07-15-2010, 07:40 AM

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