Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Location
    Bangor, ME USA
    Posts
    44

    Red face Unanswered: Help with open and close procedures

    The code I have below is two separate functions where the first on fires when the DB is first opened and logs the User as having the database open. This works just fine and has no problems. The second one howver does not work, when I have the where clause as part of the Openform statement. If I take the clause out it finds the form but then I cant filter the records I want in order to put in the time they logged out correctly. "I think it is the where clause that is wrong" Any Help with what I already have would be appreciated. If I can get this to work then I can explore other ways. Also can someone give me the steps to do a global Boolean and what the advantages are and where to put them and how they are used.

    Code:
    Option Compare Database
    Option Explicit
    ___________________________________________________________
    Function DB_OpenCode() ' This code WORKS
    
    DoCmd.OpenForm "UseLogger_Frm", Normal, , , acAdd, Hidden
    
    Forms!UseLogger_Frm.Time_In = Now()
    Forms!UseLogger_Frm.DB_Logon_Name = CurrentUser
    Forms!UseLogger_Frm.Net_Login_Name = Environ("Username")
    Forms!UseLogger_Frm.Net_Machine_Name = Environ("ComputerName")
    Forms!UseLogger_Frm.Net_Domain = Environ("UserDomain")
    Forms!UseLogger_Frm.DBL_NLN_NMN_ND = Forms!UseLogger_Frm.DB_Logon_Name & _
      " -- " & Forms!UseLogger_Frm.Net_Login_Name & " -- " & _
      Forms!UseLogger_Frm.Net_Machine_Name & " -- " & Forms!UseLogger_Frm.Net_Domain
    
    Forms!UseLogger_Frm.Dirty = False
    
    Call jpDelay(1000)
    
    DoCmd.Close
    
    Call Check_User
    
    End Function
    ________________________________________________________________
    Function DB_CloseCode() ' This code DoesNOT WORK
    
    DoCmd.OpenForm "UseLogger_Frm", acNormal, , "Forms!UseLogger_Frm.DB_Logon_Name = CurrentUser" And "Forms!UseLogger_Frm.Net_Login_Name = Environ('Username')" And _
      "Forms!UseLogger_Frm.Net_Machine_Name = Environ('ComputerName')" And _
      "Forms!UseLogger_Frm.Net_Domain = Environ('UserDomain')" And IsEmpty(Forms!UseLogger_Frm.Time_Out), acFormEdit, acHidden
      
      Forms!UseLogger_Frm.Time_Out = Now()
      
      Forms!UseLogger_Frm.Dirty = False
    
    Call jpDelay(1000)
    
    DoCmd.Close
    
    End Function
    any suggestions on the where clause also may be of use to me. Also now the Open code above does not close the form anymore and I dont know why.

    TIA
    Kevin

    So far I have 19 views but no replies.
    Help???
    Last edited by Kmcarman72; 12-08-04 at 20:07. Reason: Easier to read / retitle

  2. #2
    Join Date
    Nov 2004
    Location
    Bangor, ME USA
    Posts
    44
    The Message I Get now after trying to get this f---- to work is Run-time Error '2450'

    Microsoft Access can not find form 'UseLogger_Frm' Referenced in visual basic or a macro. The form is there but it doesn't see it


    HELPPPPPPP
    I have been fighting with this piece of code for 3 weeks

  3. #3
    Join Date
    Sep 2003
    Posts
    228
    I believe you may need to set the focus to that hidden form before setting the values of its controls.

  4. #4
    Join Date
    Nov 2004
    Location
    Bangor, ME USA
    Posts
    44
    I have tried just typing the where clause within the do.cmd openform "Uselogger_Frm", ancormal,,Heres the where clause, achidden and it still can not find the form so I dont think thats it and how woudl I do it if I want the form to open with just the record that needs to be editied and nothing else. You create a where clause to filter just that record. When the thing does work it doesn't filter the records. so I'm still screwed.

    Thanks anyways
    Kevin

Posting Permissions

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