Runtime Error 3075 (Syntax Error)

I've looked through a lot of the posts related to the "run-time error 3075" with regards to "syntax error", but none seem to be similar to the problem I am having...

Rather than me typing out a long explanation as to what I am encountering, I recorded what is happening - so, this link: Runtime Error

will show you what I'm encountering...

I thank you in advance for information you may have to help me solve this problem...

Carl

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

It appears you are getting this error when you select a NEW record. Since an ID has not been generated at the time, the WHERE clause you are trying to use is invalid. 

Replace your strCriteria line with: 

If Me.NewRecord Then

       strCriteria = ""

Else

       StrCriteria = "what you have now"

End If

It should now work.

P.S. it would have been easier to do a screen shot with the error message and the code behind it.

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Microsoft Access MVP since 2007

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Thank you, Scott - appreciate the quick response...

I will enter the code as you suggest, then let you know if it works...

I thought about using screen shots, but opted for the video to show what was happening...  Since posting, I have looked at my project and to tell you the truth it is probably not setup as it should be...

I will play around with it some more and see if I can get it to work the way I envision it...

If it would help for you to actually look at the database on your end, let me know how I can send you a copy of the file...

There is, as I'm sure you are aware of, tons and tons of Access instructions, videos, tutorials, etc. on the Internet - all well and good, but it can be somewhat of an "information overload" for my style of learning...  :-)

Thanks again for your response - it is appreciated...  I will let you know if your coding suggestion works...

Carl

"...life is what happens to you while you're busy making other plans..." JL

1 person was helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

It has been awhile since I last posted to my question, so here's an update...

I've come to the conclusion that what I need to learn alongside learning Access, is learning VB as well...  A tall order, but when one is retired, time is all one has...

So, I will continue to plod along trying different approaches to get to what I envision as to what I think should happen and what I want to happen when a user uses the database I am trying to create...

I have happened upon some websites (see links below) that I am currently muddling through to acquire the Access "knowledge" I need to get the current database I'm working on to work the way I want it to and for future databases I may try to create...

As Scott is the only one, so far, who has responded to my question - thank you, sir - I appreciate your information (unfortunately, it didn't work, but I'll keep trying)...  I've added your blog to my "bookmarks" as another source to tap into for computer related stuff...

Access Video Tutorial: https://www.youtube.com/watch?v=kmECCLqkQtY

Everything Access Tutorials: http://www.everythingaccess.com/tutorials.asp

Access MVP: http://www.accessmvp.com/strive4peace/

"...life is what happens to you while you're busy making other plans..." JL

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

First, you need to learn VBA, not VB. While the two are similar they are not the same. VBA is a superset of VB in that it contains much of the procedural language of VB, but also it contains classes and object specific to the application you are working with, which VB doesn't have.

Second, what about my suggestion didn't work? I suspect the reason no one else answered was because my solution was the obvious one.. If it didn't work, then something more is going on and we need to know what.

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Microsoft Access MVP since 2007

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Scott...  First of all, you are correct about the "VBA" thing; that is what I was thinking, but the connection from my brain to my fingers typing on the keyboard - well, let's just say it was a proverbial "brain fart"...  Apologies for "offending" your "expertise sensibility"...  I used to be like that but came to discover not everyone is an expert so I give them room for making mistakes and only remind them if it would become a repeated mistake over a long period of time in instructing them in whatever it would be at the time...

Second, in a "perfect world" your suggestion would probably have worked if the person - me in this case - knew **** they were doing - I do not... :-)

Your suggestion:

If Me.NewRecord Then

       strCriteria = ""

Else

       StrCriteria = "what you have now"

End If

Here's the code before plugging in your suggestion:  

Private Sub KeyNumber_Click()
Dim strDocName As String
    Dim strLinkCriteria As String
    strDocName = "KeyCabinet 01"

    strLinkCriteria = "[Cabinet01_ID]=" & Me![Cabinet01_ID]
    DoCmd.OpenForm strDocName, , , strLinkCriteria
End Sub

Here's the code after plugging in your suggestion:

Private Sub KeyNumber_Click()
Dim strDocName As String
    Dim strLinkCriteria As String
    strDocName = "KeyCabinet 01"
    
If Me.NewRecord Then
       strCriteria = ""
Else
    strCriteria = "[Cabinet01_ID]=" & Me![Cabinet01_ID]
End If

End Sub

After plugging in your suggestion, then running it, it didn't work, so it is obvious to me I do not know **** I'm doing, so unless you are totally bored out of your mind with nothing to do, don't worry about trying to figure out what I'm doing incorrectly...  But, if you are "bored out of your mind", I'll send the file to you so you can really see how bad it is, then let me know if it is beyond "fixing"... 

"...life is what happens to you while you're busy making other plans..." JL

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

What means "didn't work"? Remember you can see what is happening, we can't. I took a guess at the cause of your problem, mainly because you didn't give us enough info.,

And I wasn't annoyed, but Access requires using precise terminology to get things across. So I didn 't know whether you just left of the A or wasn't sure if VB and VBA were interchangeable. 

If you want to upload the file to cloud storage I'll try to take a look at it.

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Microsoft Access MVP since 2007

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

What email address do I send you the DropBox link to the file...?

The file will be a zip file if that is okay...

"...life is what happens to you while you're busy making other plans..." JL

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Private Sub KeyNumber_Click() 
Dim strDocName As String Dim strLinkCriteria As String 
strDocName = "KeyCabinet 01"

If Me.NewRecord Then strCriteria = "" 
Msgbox "no criteria !"
Else 
strCriteria = "[Cabinet01_ID]=" & Me![Cabinet01_ID] 

 DoCmd.OpenForm strDocName, , , strLinkCriteria 
End IF

End Sub

Try the codes above.

And an vedio on youTube maybe not convenient to visit.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.



Try the codes above.


Umm, that's the same code I gave him excpet you added a message box? What is the message box supposed to do?

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Microsoft Access MVP since 2007

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Yes, your code completely.
I have not seen his vedio.
So, I guess he maybe need a reminder for no criteria.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

 
 

Question Info


Last updated April 5, 2019 Views 258 Applies to: