Results 1 to 11 of 11
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    DCount looking for a "("

    Compiler complaining that the DCount statment is invalid, requiring a "(". Seems that the problem is somehow more basic with regards to the syntax, but I haven't found it. I've tried "[NameExp] = """ & strComp & """" as the criteria, but that doesn't work either. What am I missing here?

    Code:
    Public Sub LoadtblGFM()
    Dim rsSav As DAO.Recordset
    Dim strSplit() As String
    Dim strFName As String
    Dim strLName As String
    Dim strComp As String
    
    
    strSplit = Split(strLine, " ")
    strLName = strSplit(UBound(strSplit))
    strFName = Left(strLine, Len(strLine) - Len(strLName))
    strComp = strLName & "," & strFName
    Set rsSav = DBEngine(0)(0).OpenRecordset("QGFM")
    
    
        rsSav.AddNew
        rsSav!LastName = strLName
        rsSav!Firstname = strFName
        rsSav!Donation = stramount
            If DCount("[NameExp]", "QADFnames", "[NameExp] = " & strComp) > 0 Then _
            rsSav!FLMember = True
        rsSav.Update
    
    
    rsSav.Close
    Set rsSav = Nothing
    
    
    End Sub


  2. #2
    Edgar is online now Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    StrComp is a function
    https://learn.microsoft.com/en-us/of...rcomp-function

    Just change the name of that variable.
    Please click on the ⭐ below if this post helped you.


  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If NameExp is a text field, need apostrophe delimiters in criteria.

    Why don't you use * wildcard instead of field name?

    Why use a string variable for numeric data?

    Where do strLine and stramount get populated?
    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.

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks Edgar, that cleared things up.
    Funny that the compiler didn't "wrap my knuckles" when I "Dim strComp As String"

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    If NameExp is a text field, need apostrophe delimiters in criteria.
    Yes, I noted that in the OP
    And yes, I could very well have used "*". My focus was on the field of interest at the time.

    Where do strLine and stramount get populated?
    Both are global to the module and set before LoadtblGFM sub is called.

    Why use a string variable for numeric data?
    Everything is string. Don't know where you're seeing numeric data?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Donation field is not numeric? You populate it with stramount - that is not money?

    VBA does not warn that variable names conflict with reserved words such as intrinsic functions.
    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.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Donation field is not numeric? You populate it with stramount - that is not money?
    Probably a bit deceiving. It's a string from some line input already formatted as such, e.g., $100.00. Normally, such values are contained in fields with Currency format properties and would be treated in code as such. But again, from the input line I'm given a string.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Interesting. I just tested an UPDATE action to set Double number field with a string value of "$100.00". Access (query object and CurrentDb.Execute) performed implicit conversion and accepted the input. Never had to consider that before.
    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.

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Well the line-in left me with strings like "$100.00 (Est)" and "$40.50 (rebate)", etc left me with not much choice as to how I had to deal with the data types. Your points are, however, well taken.
    Bill

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Guess only alternative would be splitting data to appropriate fields. Seems to be enough consistency it shouldn't be too difficult.
    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.

  11. #11
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    @GraeagleBill - thanks for destroying my long held belief that if you 'typed' your variables with prefixes like str, dbl, int, lng, etc. you could never go wrong!!
    strComp?? You would have to know to know.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-02-2023, 09:25 AM
  2. Replies: 1
    Last Post: 01-30-2022, 11:05 PM
  3. Dcount results in error "Overflow"
    By skydivetom in forum Programming
    Replies: 5
    Last Post: 07-14-2021, 09:53 AM
  4. Simple table relationships ("faces" to "spaces" to "chairs")
    By skydivetom in forum Database Design
    Replies: 36
    Last Post: 07-20-2019, 01:49 PM
  5. Replies: 1
    Last Post: 09-07-2015, 08:00 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