Avatar of PipMic
PipMicFlag for Gibraltar asked on

Private sub Error

Hi all,

I have the following code in A97 but I am getting a error 3075.Grateful if someone can debug.

Private Sub mcr_A_Click()
Dim dtext As String

    dtext = Forms![frmA]![Combo2]
    If DCount("*", "Table1", "[txt] = " & dtext) > 0 Then
            MsgBox "Routine will be aborted, data to be appended already exists.", vbCritical
        DoCmd.RunMacro "macro_Z"
    End If
End Sub
Microsoft Access

Avatar of undefined
Last Comment
Jim Dettman (EE MVE)

8/22/2022 - Mon
Jim Dettman (EE MVE)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks Jim, it worked...

May I ask why the need for chr$(34)?

Thanks just figured it out .... many thanks again
Jim Dettman (EE MVE)

When you're giving a string value, it must be delimited either with " or '.  Many would write that statement like this:

DCount("*", "Table1", "[txt] = '" & Forms![frmA]![Combo2] & "'")

The result of the last argument when parsed by Access is:

 [txt] = 'some value'

You also could use a quote ("), but then you need to double it all up:

DCount("*", "Table1", "[txt] = "" & Forms![frmA]![Combo2] & """)

(and I may not have that quite right, but suffice to say using " inside of a string argument is just a pain).

But even if you just use ',  depending on the font and size your using, that can be difficult to read and tell if you have:



Chr$(34) gives you a quote ("), without using the quote character, so it's a lot easier to read and a lot more obvious exactly what it is your doing.

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck