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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|