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

    Unhappy Unanswered: Going crazy! Help with quotes in a where statement

    I have this is a different thread with an obscure title. I have two functions to log when people sign in and out of a multiuser database. When it works it will allow me to see who is still in a database so I can have them shut down so I can do maintenance. My first function is fine DB_Opencode() works perfectly as it just adds a new record and closes (no one sees this happen).

    Code:
    Option Compare Database
    Option Explicit
    
    Function DB_OpenCode()
    
    DoCmd.OpenForm "UseLogger_Frm", acFormDS, , , acAdd, acHidden
    
    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.Time_Out = #12:00:00 AM#
    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
    
    Forms!UseLogger_Frm.Visible = True
    
    DoCmd.Close
    
    Call Check_User
    
    End Function
    the above works just fine (to create table and form just copy the fieldnames and make time_in and Time_Out as date time and the last field that combines the other 4 at 255. That way you can see if it works for you first. My second function Below does not work as I can not figure out the quotes properly. The fld6v when put in immediate window and debug.print does come up correctly but when put in the openform where clause will not work at all as it filters nothing on the form.

    Code:
    Function DB_CloseCode()
    
    Dim fld6V As String
    
    fld6V = CurrentUser & " -- " & Environ("UserName") & " -- " & Environ("Computername") & " -- " & Environ("Userdomain")
    
    DoCmd.OpenForm "UseLogger_Frm", acNormal, , "[Forms]![UseLogger_Frm].[DBL_NLN_NMN_ND] = '"fld6V"'", acFormEdit, acHidden
      
    [Forms]![UseLogger_Frm].[Time_Out] = Now()
      
    Forms!UseLogger_Frm.Dirty = False
    
    Forms!UseLogger_Frm.Visible = True
    
    DoCmd.Close
    
    End Function
    Any and all help would be appreciated.

    I have tried just about every combination of [] and & and whatever else I could think of and it either filters nothing and adds a new record with nothing but a Time_out (which is useless to me) or it says it cant find the form, or syntax error (missing operator) or some type mismatch. I've seen it all.


    Helllllp Pleeeeeeeeeas

    TIA
    Kevin

  2. #2
    Join Date
    Sep 2004
    Location
    Reston, VA
    Posts
    86
    Looks like the problem is with the WHERE clause in your OpenForm line. You shouldn't have to put [Forms]![UseLogger_Frm] in the clause, and you're also missing the & symbols to concatenate your fld6V variable with. Try this instead:

    DoCmd.OpenForm "UseLogger_Frm", acNormal, , "[DBL_NLN_NMN_ND]='" & fld6V & "'", acFormEdit, acHidden

  3. #3
    Join Date
    Nov 2004
    Location
    Bangor, ME USA
    Posts
    44
    BummerJeff,

    Thanks. Your statement worked and when I added an & [Time_out] = #12:00:00 AM# now the function does what I want it to.

    Very Much Obliged
    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
  •