A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Setting a Querey def



 
 
Thread Tools Display Modes
  #1  
Old October 25th, 2006, 02:35 PM posted to microsoft.public.access.forms
mike
external usenet poster
 
Posts: 3,942
Default Setting a Querey def

I have a form with a print preview button (and print for that matter). when
a user clicks on the button, a report is to be previewed (printed) that
contains the information displayed. (taken from a field, CoilID) i've done
in the past some VBA where is make a string that contains the SQL statement
to select the proper record, but i forgot how. could someone help me out?
here's a bit of what i think.

Dim strRptQry As String
Dim dbsC1894 As Database
Dim rstRPTQRY as Recordset
Dim stDocName As String

strRptQry = "Select...."
strRptQry = strRptQry + "more stuff.."
'end of SQL statment string

Set dbsC1984 = CurrentDb
set rstRPTQRY = dbsC1894.OpenRecordset("qryReport")

rstRPTQRY.Open(srtRptQry)

stDocName = "rptScreen"
DoCmd.OpenReport stDocName, acPreview, ,

something along those lines. any help would be appreciated!

  #2  
Old October 25th, 2006, 02:42 PM posted to microsoft.public.access.forms
Roger Carlson
external usenet poster
 
Posts: 222
Default Setting a Querey def

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "CreateQueries2.mdb" which illustrates how to do this.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L


"Mike" wrote in message
...
I have a form with a print preview button (and print for that matter).

when
a user clicks on the button, a report is to be previewed (printed) that
contains the information displayed. (taken from a field, CoilID) i've

done
in the past some VBA where is make a string that contains the SQL

statement
to select the proper record, but i forgot how. could someone help me out?
here's a bit of what i think.

Dim strRptQry As String
Dim dbsC1894 As Database
Dim rstRPTQRY as Recordset
Dim stDocName As String

strRptQry = "Select...."
strRptQry = strRptQry + "more stuff.."
'end of SQL statment string

Set dbsC1984 = CurrentDb
set rstRPTQRY = dbsC1894.OpenRecordset("qryReport")

rstRPTQRY.Open(srtRptQry)

stDocName = "rptScreen"
DoCmd.OpenReport stDocName, acPreview, ,

something along those lines. any help would be appreciated!



  #3  
Old October 25th, 2006, 03:38 PM posted to microsoft.public.access.forms
mike
external usenet poster
 
Posts: 3,942
Default Setting a Querey def

thanks, that helped. i just am wondering how to add a " into a string.

like str = "beginning of string with(")a quotation(") here"

i.e. i need quotation marks within the beginning/end quotations marks
denoting a string.



"Roger Carlson" wrote:

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "CreateQueries2.mdb" which illustrates how to do this.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L


"Mike" wrote in message
...
I have a form with a print preview button (and print for that matter).

when
a user clicks on the button, a report is to be previewed (printed) that
contains the information displayed. (taken from a field, CoilID) i've

done
in the past some VBA where is make a string that contains the SQL

statement
to select the proper record, but i forgot how. could someone help me out?
here's a bit of what i think.

Dim strRptQry As String
Dim dbsC1894 As Database
Dim rstRPTQRY as Recordset
Dim stDocName As String

strRptQry = "Select...."
strRptQry = strRptQry + "more stuff.."
'end of SQL statment string

Set dbsC1984 = CurrentDb
set rstRPTQRY = dbsC1894.OpenRecordset("qryReport")

rstRPTQRY.Open(srtRptQry)

stDocName = "rptScreen"
DoCmd.OpenReport stDocName, acPreview, ,

something along those lines. any help would be appreciated!




  #4  
Old October 25th, 2006, 05:04 PM posted to microsoft.public.access.forms
Roger Carlson
external usenet poster
 
Posts: 222
Default Setting a Querey def

Replace the individual quotes with two quotes (""). If you are inserting
variables, this can look odd, but something like this:

Str = "Select * from MyTable where FirstName = """ & variable & """"

you can replace the the two quotes with an apostrophe:

Str = "Select * from MyTable where FirstName = '" & variable & "'"

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L



"Mike" wrote in message
news
thanks, that helped. i just am wondering how to add a " into a string.

like str = "beginning of string with(")a quotation(") here"

i.e. i need quotation marks within the beginning/end quotations marks
denoting a string.



"Roger Carlson" wrote:

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "CreateQueries2.mdb" which illustrates how to do this.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L


"Mike" wrote in message
...
I have a form with a print preview button (and print for that matter).

when
a user clicks on the button, a report is to be previewed (printed)

that
contains the information displayed. (taken from a field, CoilID) i've

done
in the past some VBA where is make a string that contains the SQL

statement
to select the proper record, but i forgot how. could someone help me

out?
here's a bit of what i think.

Dim strRptQry As String
Dim dbsC1894 As Database
Dim rstRPTQRY as Recordset
Dim stDocName As String

strRptQry = "Select...."
strRptQry = strRptQry + "more stuff.."
'end of SQL statment string

Set dbsC1984 = CurrentDb
set rstRPTQRY = dbsC1894.OpenRecordset("qryReport")

rstRPTQRY.Open(srtRptQry)

stDocName = "rptScreen"
DoCmd.OpenReport stDocName, acPreview, ,

something along those lines. any help would be appreciated!






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.