Results 1 to 3 of 3
  1. #1
    jeffhanner is offline Advanced Beginner
    Windows 10 Access 2019
    Join Date
    Sep 2022
    Location
    Lincolln, CA
    Posts
    40

    DoCmd.BrowseTo with variable as datamode

    I'm using this part of the code to open a form in a subform. I want to assign a variable to the datamode which is based on the username.
    When I declare the variable as a string then the error is Type Mismatch



    Code:
    Dim ACMode As String
    ACMode = "ACformReadOnly"
    ' m_Callform is the name of the form, which is passed via the Function
    
    DoCmd.BrowseTo acForm, mCallForm, "frmSCD.NavigationSubform",[SNUmbr]=" & TempVars!TempSNumber, "", ACMode
    Note: Normally I just have this:

    DoCmd.BrowseTo acForm, mCallForm, "frmSCD.NavigationSubform",[SNUmbr]=" & TempVars!TempSNumber, ""

    Which creates an edit mode.

    I could use a conditional statement here, which is based on the user name, but I have too many screens for that.

    Any Suggestions?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Missing first quote mark in the WHERE CONDITION argument.

    Also, can't pass "ACformReadOnly" as a string to DataMode argument. It expects a numeric value and it cannot evaluate "ACformReadOnly". This is just a string of characters and triggers the mismatch error.

    acFormReadOnly is a constant with value of 2 so either:

    ACMode = 2

    or

    ACMode = acFormReadOnly

    As far as I can tell, ACMode is not an intrinsic constant but I would not use ac as a prefix.

    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
    jeffhanner is offline Advanced Beginner
    Windows 10 Access 2019
    Join Date
    Sep 2022
    Location
    Lincolln, CA
    Posts
    40
    I'm sorry to respond late, however, the information you provided was very helpful and I was able to resolve the issue.

    Thank you.

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

Similar Threads

  1. WhereConditions in DoCmd.BrowseTo functions
    By jeffhanner10@gmail.com in forum Programming
    Replies: 2
    Last Post: 04-07-2020, 05:05 AM
  2. DoCmd.RunSql with a variable
    By ngooo in forum Modules
    Replies: 6
    Last Post: 11-24-2017, 10:00 AM
  3. Docmd.browseto where condition
    By mjdemaris in forum Forms
    Replies: 5
    Last Post: 02-16-2016, 03:33 PM
  4. Replies: 8
    Last Post: 06-19-2014, 04:20 PM
  5. DataMode
    By RHall in forum Programming
    Replies: 1
    Last Post: 01-26-2006, 10:23 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