Results 1 to 3 of 3
  1. #1
    jabarlee is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2018
    Posts
    49

    Differences in string formation


    Hello everyone.

    I would like to ask, what is the difference between the 2 following cases:

    1.
    Code:
    Dim strFormName As String
    strFormName = Left$(Me.OpenArgs, intPos - 1)
    Forms("frm_Meds").Controls("" & strFormName & "").Form!cbo_Med.Requery
    where strFormName = frm_Meds

    2.
    Code:
    Dim strFormName As String
    strFormName = Chr(34) & Left$(Me.OpenArgs, intPos - 1) & Chr(34)
    Forms("frm_Meds").Controls(strFormName).Form!cbo_Med.Requery
    where strFormName = "frm_Meds"

    In the 1st case everything works ok.
    In the 2nd case I get an '2465' run-time error: The database can't find the field "frm_Meds" referred to in your expression

    I would expect that it would be the same, but clearly, it isn't. Why's that?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you use " to define a string. Openargs is already a string

    this will work just as well, you don't need to add zero length strings

    Forms("frm_Meds").Controls(strFormName).Form!cbo_M ed.Requery

    or just

    Forms("frm_Meds").Controls(Left$(Me.OpenArgs, intPos - 1)).Form!cbo_Med.Requery

  3. #3
    jabarlee is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2018
    Posts
    49
    Ajax, thanx.

    I swear that when I first tried I used
    Code:
    Forms("frm_Meds").Controls(strFormName).Form!cbo_Med.Requery
    and I got some error. I can't reproduce it now, obviously there was something else wrong.
    This works just fine now, thanx again

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

Similar Threads

  1. Calculation - formation of digits
    By stephenchan433 in forum Access
    Replies: 3
    Last Post: 01-16-2016, 08:49 PM
  2. Show differences on chart
    By Skizzly in forum Queries
    Replies: 13
    Last Post: 09-30-2015, 01:02 PM
  3. How to calculate differences
    By ghodgkins in forum Access
    Replies: 5
    Last Post: 06-24-2015, 12:01 PM
  4. Calculating Multiple Differences
    By dr4ke1990 in forum Queries
    Replies: 58
    Last Post: 01-02-2014, 12:34 PM
  5. Replies: 8
    Last Post: 03-19-2013, 07:55 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