UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> External Name Not Defined, Access 2013    
 
   
pensived
post Mar 13 2019, 12:31 PM
Post#1



Posts: 92
Joined: 21-February 12



Hello everyone, hoping I'm missing something small,
the code below works until I add "And [CAD] = "& True &""

Then I get the error "External name not defined" on Form!ProjectNo

CODE
strSQL = "SELECT [link] FROM attachmentstbl WHERE [Projectno] = '" & Forms![projectfrm].Form!ProjectNo & "'" And [CAD] = "& True &"


Any idea what I'm doing wrong?

Thank you
Go to the top of the page
 
nuclear_nick
post Mar 13 2019, 12:41 PM
Post#2



Posts: 1,767
Joined: 5-February 06
From: Ohio, USA


True is true, false is false...

CODE
strSQL = "SELECT [link] FROM attachmentstbl WHERE [Projectno] = '" & Forms![projectfrm].Form!ProjectNo & "'" And [CAD] = True"


So try it that way...

--------------------
"Nuclear" Nick
____________
The top three reasons to hide code; 1) It's not your own. 2) It's your own, but it's so crappy you don't want anyone to see it. 3) The comments in your code would get you in a lot of trouble if ever made public.
Go to the top of the page
 
MadPiet
post Mar 13 2019, 12:43 PM
Post#3



Posts: 3,207
Joined: 27-February 09



First off, don't put True in quotes. It's not a text string.

CODE
SELECT WorkTimes.EmployeeID, WorkTimes.Okay
FROM WorkTimes
WHERE (((WorkTimes.Okay)=True));


(the query editor built that). Notice the lack of quotes.

You could also use -1:

CODE
SELECT WorkTimes.EmployeeID, WorkTimes.Okay
FROM WorkTimes
WHERE (((WorkTimes.Okay)=-1));


(I think anything but 0 (false) would work)
Go to the top of the page
 
pensived
post Mar 13 2019, 01:11 PM
Post#4



Posts: 92
Joined: 21-February 12



Tried it, says expected end of statement??
Go to the top of the page
 
pensived
post Mar 13 2019, 01:13 PM
Post#5



Posts: 92
Joined: 21-February 12



even this allows me to save the code, but fails with the same error

CODE
strSQL = "SELECT [link] FROM attachmentstbl WHERE [Projectno] = '" & Forms![projectfrm].Form!ProjectNo & "'" And [CAD] = True
Go to the top of the page
 
River59
post Mar 13 2019, 01:14 PM
Post#6



Posts: 1,734
Joined: 7-April 10
From: Detroit, MI


Insert a semi colon before the end double quote

--------------------
Remember ... Armstrong, Aldrin and Collins flew to the moon and back with a computer system less complex than a modern, programmable toaster ...
Go to the top of the page
 
nuclear_nick
post Mar 13 2019, 01:15 PM
Post#7



Posts: 1,767
Joined: 5-February 06
From: Ohio, USA


Oh.

That would be a tiny bit of proofreading on my part...
CODE
strSQL = "SELECT [link] FROM attachmentstbl WHERE [Projectno] = '" & Forms![projectfrm].Form!ProjectNo & "' And [CAD] = True"

... just an extra " that didn't belong.

--------------------
"Nuclear" Nick
____________
The top three reasons to hide code; 1) It's not your own. 2) It's your own, but it's so crappy you don't want anyone to see it. 3) The comments in your code would get you in a lot of trouble if ever made public.
Go to the top of the page
 
pensived
post Mar 13 2019, 01:15 PM
Post#8



Posts: 92
Joined: 21-February 12



NVM, I got it, thx everyone who replied


CODE
strSQL = "SELECT [link] FROM attachmentstbl WHERE [Projectno] = '" & Forms![projectfrm].Form!ProjectNo & "' And [CAD] = True"
Go to the top of the page
 
pensived
post Mar 13 2019, 01:15 PM
Post#9



Posts: 92
Joined: 21-February 12



LOL Great minds. Thank Nick
Go to the top of the page
 
nuclear_nick
post Mar 13 2019, 01:16 PM
Post#10



Posts: 1,767
Joined: 5-February 06
From: Ohio, USA


I'm glad you found it as well... means you're learning... smile.gif

Good luck with your project!

--------------------
"Nuclear" Nick
____________
The top three reasons to hide code; 1) It's not your own. 2) It's your own, but it's so crappy you don't want anyone to see it. 3) The comments in your code would get you in a lot of trouble if ever made public.
Go to the top of the page
 
gemmathehusky
post Apr 25 2019, 10:06 AM
Post#11


UtterAccess VIP
Posts: 4,725
Joined: 5-June 07
From: UK


strSQL = "SELECT [link] FROM attachmentstbl WHERE [Projectno] = " & chr(34) & Forms![projectfrm].Form!ProjectNo & chr(34) & " And [CAD] = " & True


fwiw, I always use chr(34) to embed a " character.
I would have used true outside the string and let the compiler handle it.

I would have ended up with the above string which I presume would have worked.

--------------------
Dave (Male)

(Gemma was my dog)
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    21st August 2019 - 02:12 AM