Results 1 to 13 of 13
  1. #1
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50

    Unanswered: Moved dB - Now Can't Save Records

    Created dB w/ user-level security on my computer. Copied and Pasted the dB and Secured files to LAN. Can only save or update records from orig computer.

    As you can see from the code below, when record is saved or updated, it is tagged with the current username. When record is saved or updated via any other computer, debugger pops up - pointing specifically to line 5 - 'sUsername = String (15, " ")'.



    Private Function GetUser() As String
    Dim sUserName As String
    Dim lgSize As Long
    Dim lgLength As Long
    sUserName = String(15, " ")
    lgSize = Len(sUserName)
    lgLength = GetUserName(sUserName, lgSize)
    GetUser = Left(sUserName, lgSize - 1)
    End Function

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    '
    'Purpose: To fill in the "Date Created", "Date Modified", and "CreatorUser" Fields
    If IsNull(Me![DATECREATED]) Then
    Me![DATECREATED] = Now()
    Me![CREATORUSER] = GetUser
    Else
    Me![DATEMODIFIED] = Now()
    Me![MODIFIERUSER] = GetUser
    End If
    '
    End Sub



    Any Ideas? Thanks ahead of time.

    R
    Thanks in advance or hope this helps.

  2. #2
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    When you made the user-level security on your PC, did you specify an *.mdw file or did you just have it default to the system.mdw file out under c:\windows\..?..\system.mdw?

    The user level security (groups and accounts) is stored in the *.mdw file. If the users on the network are not specifically directed to the *.mdw file you created, then, when they open the database, Access goes to their own default c:\windows\..?..\system.mdw.

    If this is helpful, do a search in this forum for more data on passwords, shortcuts, the /wrkgrp option, and mdw files.


    Regarding your code, what does the following line do?

    sUserName = String(15, " ")
    Last edited by jpshay; 03-26-04 at 12:53.
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  3. #3
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50
    I named the file Secured.MDW, and copied it along with the dB file to the server (put them in the same folder). How would you direct MSAccess from other computers to use the user-level security file on the LAN location?

    Another root to my problem could be the Workgroup, couldn't it?

    BTW, thanks for the response.

    I tried to do a search, but both in the forum and archives, I get 'cannot find this page' when I click the search button.
    Thanks in advance or hope this helps.

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by reoterq
    I named the file Secured.MDW, and copied it along with the dB file to the server (put them in the same folder). How would you direct MSAccess from other computers to use the user-level security file on the LAN location?

    Another root to my problem could be the Workgroup, couldn't it?

    BTW, thanks for the response.

    I tried to do a search, but both in the forum and archives, I get 'cannot find this page' when I click the search button.
    Run the Workgroup Administrator program on each client and redirect to the network MDW file ...

  5. #5
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    Sounds like you have already made one workgroup (an mdw file) and placed that on the network. (You have added accounts for all users via Tools/Security/User Group and Accounts, right?)

    Then a shortcut must be used for each user so that they open your MDW file, instead of their defualt mdw file.

    The target of the shortcut has three elements.
    1) the path & access.exe
    2) the path and name of the database.
    3) the path and name of the MDW file. (use the switch /wrkgrp)

    For example
    "C:\Program Files\Microsoft OfficeXP\Office10\MSACCESS.EXE" "C:\_Databases\Studies\PFO\PFO.mdb" /wrkgrp "\\Deneb\Clinical\Databases\Studies\_System\system .mdw"
    This example points to my access, my database, and a shared system.mdw on the network.
    (NB: use double quotes for paths with spaces)

    Typically starting up access points to the system.mdw established at the installation of Access. Using a shortcut you can override that.

    Caution:
    People may have Access installed in different paths, so individual shortcuts may need to be adjusted.
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  6. #6
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50
    The shortcut is correct.

    The error is 'Compile Error. Can't find project or library.' I tracked the problem down to a missing reference: MS Rich Textbox Control 6.0. I know how to get to the Reference Dialog Box and can browse for missing referred objects, but have no idea where to find the Control I'm looking for. All files with the extension I'm looking for have obscure names.

    Don't know why the Debugger consistantly points to the 'GetUser()' function.

    Know where I might find the referred Control?

    Thanks

    R.
    Thanks in advance or hope this helps.

  7. #7
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    I'm not familiar with GetUser(). Though I use CurrentUser() quite a bit. CurrentUser() is a canned Access function which is in the following library (on my machine).

       C:\Program Files\Microsoft Office XP\Office10\msacc.olb
       Microsoft Access 10.0 Object Library

    This is Access 2002, Older version probably just have a lower version for the library (e.g. Access 8.0)
    Last edited by jpshay; 03-28-04 at 09:11.
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  8. #8
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50
    GetUser() is a function that I defined through code (see orig post).
    Thanks in advance or hope this helps.

  9. #9
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    I still have the same question.

    Dim sUserName As String
    GetUser = Left(sUserName, lgSize - 1)

    I see the declaration and the setting of GetUser, but I don't see what is setting the variable sUserName. Unless I am missing something, I think your code is wrong. The fact the debugger stops at that line supports my hunch. That is why I suggest trying the function CurrentUser(). Let me know if I'm wrong. Check out the function "CurrentUser()" in the help, it may give you what you want.
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  10. #10
    Join Date
    Mar 2004
    Location
    Tulsa, OK
    Posts
    50
    My help says zippo about CurrentUser(). What does the function do?

    I was able to fix my problem by just unchecking the unknown control (Rich Textbox Control 6.0) from the references dialog. I don't know why it was including the control, but would like to know how to locate and include it should I ever need it.

    I had tried to understand this code and run into the same question about the string() function, but being new to programming and having a 'library error' meant that I just didn't understand libraries. The code is borrowed code, but was accompanied with high detail instructions, which were followed closely and again on a second day. I'm going to go in and consolidate (remove the seemingly useless code) to see if the function changes its attitude.

    Thanks for your attention to detail and your patience.

    R
    Thanks in advance or hope this helps.

  11. #11
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    Hello again.

    Regarding help: there may be three reasons you don't see any help on the topic.
    1) you are not looking at help from the code desing screen (Microsoft Visual Basic). Sometimes I see a difference when looking at help from the database side versus the code side.
    2) you don't have the help for VBA installed. This can be individually selected at install or updated by reinstalling and selecting just the help section.
    3) Perhaps the help is limited to the libraries that are referenced. (I'm not positive about this). If you create a reference to the library below, then you will be able to read about it in the help.

    C:\Program Files\Microsoft Office XP\Office10\msacc.olb
    Microsoft Access 10.0 Object Library

    This is Access 2002, Older version probably just have a lower version for the library (e.g. Access 8.0)


    Regarding the code:
    Private Function GetUser() As String
      Dim sUserName As String
      Dim lgSize As Long
      Dim lgLength As Long

      sUserName = String(15, " ") this initializes the string so that it is a string of 15 blanks
      lgSize = Len(sUserName) the lgSize is set to 15
      lgLength = GetUserName(sUserName, lgSize) this calls a function. I'm guessing this function sets the string 'sUserName' to CurrentUser(). Investigate this function.
      GetUser = Left(sUserName, lgSize - 1)
    End Function

    Seems like a goofy function, but I don't know what the rest of the code is doing. The main point is that there is probably a line of code somewhere that sets sUserName = CurrentUser(). Do a search - selecting current project - for CurrentUser or for all occurences of sUserName.

    hope this helps.
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  12. #12
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    New Insight!

    I bet that the username your database is getting is not the MS Access username from an *.mdw file, but the username from the network. Regarding this, I know little.

    I wrote the following

    lgLength = GetUserName(sUserName, lgSize) this calls a function. I'm guessing this function sets the string 'sUserName' to CurrentUser(). Investigate this function.

    I'm pretty sure that this is a call to get the network login name.

    Private Declare Function apiGetUserName Lib "ADVAPI32.DLL" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long


    hammbakka (the Grand Poobah) who has posted many times to this forum recently posted these bits of code to get the netowrk username.

    Private Declare Function apiGetUserName Lib "ADVAPI32.DLL" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

    Function LoggedName() As String
    ' Returns the network login name
      Dim lngLen As Long, lngX As Long
       Dim strUserName As String
       strUserName = String$(254, 0)
       lngLen = 255
       lngX = apiGetUserName(strUserName, lngLen)
       If (lngX > 0) Then
         LoggedName = Left$(strUserName, lngLen - 1)
       Else
         LoggedName = vbNullString
       End If
    End Function

    If your debugger is still halting on the same line of code, perhaps 'hammbakka' can help you.
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  13. #13
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    John ( jpshay) is right ... There is a big difference between the NETWORK username and the Access logon ID ... They can be the same but only if the network username/logon ID is setup as an account within Access ...

Posting Permissions

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