By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

Help: Continue String Code to next line

P: n/a
ok, I'm trying to write a string code and currently the code works
however I've run out of room and I need to change some of the source
names it pulls from. Changing the source names create the string
longer and there is no room left. I need to know how I can split this
into two or more lines so I can update the code now and in the future.

strSQL = "SELECT tblEmployees.LastName, tblOutputs.OutputName,
tblBudgetedFigures.BudgetedTime, Sum(tblTimesheetEntries.Hours) AS
SumOfHours, [SumOfHours]/[BudgetedTime] AS PercentUsed,
tblSections.SectionID, tblSections.Section,
Sum(tblTimesheetEntries.TravelExpenses) AS SumOfTravelExpenses,
tblBudgetedFigures.TravelExpenses, IIf([Sumoftravelexpenses]=0,0,
[SumofTravelExpenses]/[tblbudgetedfigures].[TravelExpenses]) AS
PercentUsedTravel FROM tblSections INNER JOIN (tblOutputs INNER JOIN
((tblEmployees INNER JOIN tblBudgetedFigures ON
tblEmployees.EmployeeID = tblBudgetedFigures.EmployeeName) INNER JOIN
tblTimesheetEntries ON tblEmployees.EmployeeID =
tblTimesheetEntries.EmployeeID) ON (tblOutputs.OutputID =
tblTimesheetEntries.Output) AND (tblOutputs.OutputID =
tblBudgetedFigures.OutputName)) ON tblSections.SectionID =
tblEmployees.Section GROUP BY tblEmployees.LastName,
tblOutputs.OutputName, tblBudgetedFigures.BudgetedTime,
tblSections.SectionID, tblSections.Section,
tblBudgetedFigures.TravelExpenses "

I hope someone can help, I'm fairly new to the whole
VBA coding and am updating some access databases for my office that
has this code. The code above currently runs all in a single line
which runs out of room and doesn't allow me to add more because of the
character limit. For example, I need to change tblOutputs to
tblOutputs2008, thus making the line longer however it doesn't allow
me to. What I ultimately need to do is figure out a way to split the
code onto two separate lines and have the code continue to work and
read from the end of the first line and continue at the beginning of
the second. I hope this description helps. Thanks

Oct 4 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"fhwa" <Ro**********@fhwa.dot.govschrieb
ok, I'm trying to write a string code and currently the code works
however I've run out of room and I need to change some of the source
names it pulls from. Changing the source names create the string
longer and there is no room left. I need to know how I can split
this into two or more lines so I can update the code now and in the
future.

[...]

I hope someone can help, I'm fairly new to the whole
VBA
This is not a VBA group. If you are using VB.Net (at least then):
http://msdn2.microsoft.com/en-us/lib...w4(VS.80).aspx
Armin
Oct 4 '07 #2

P: n/a
JR


"fhwa" <Ro**********@fhwa.dot.govschreef in bericht
news:11*********************@w3g2000hsg.googlegrou ps.com...
ok, I'm trying to write a string code and currently the code works
however I've run out of room and I need to change some of the source
names it pulls from. Changing the source names create the string
longer and there is no room left. I need to know how I can split this
into two or more lines so I can update the code now and in the future.

strSQL = "SELECT tblEmployees.LastName, tblOutputs.OutputName,
tblBudgetedFigures.BudgetedTime, Sum(tblTimesheetEntries.Hours) AS
SumOfHours, [SumOfHours]/[BudgetedTime] AS PercentUsed,
tblSections.SectionID, tblSections.Section,
Sum(tblTimesheetEntries.TravelExpenses) AS SumOfTravelExpenses,
tblBudgetedFigures.TravelExpenses, IIf([Sumoftravelexpenses]=0,0,
[SumofTravelExpenses]/[tblbudgetedfigures].[TravelExpenses]) AS
PercentUsedTravel FROM tblSections INNER JOIN (tblOutputs INNER JOIN
((tblEmployees INNER JOIN tblBudgetedFigures ON
tblEmployees.EmployeeID = tblBudgetedFigures.EmployeeName) INNER JOIN
tblTimesheetEntries ON tblEmployees.EmployeeID =
tblTimesheetEntries.EmployeeID) ON (tblOutputs.OutputID =
tblTimesheetEntries.Output) AND (tblOutputs.OutputID =
tblBudgetedFigures.OutputName)) ON tblSections.SectionID =
tblEmployees.Section GROUP BY tblEmployees.LastName,
tblOutputs.OutputName, tblBudgetedFigures.BudgetedTime,
tblSections.SectionID, tblSections.Section,
tblBudgetedFigures.TravelExpenses "

I hope someone can help, I'm fairly new to the whole
VBA coding and am updating some access databases for my office that
has this code. The code above currently runs all in a single line
which runs out of room and doesn't allow me to add more because of the
character limit. For example, I need to change tblOutputs to
tblOutputs2008, thus making the line longer however it doesn't allow
me to. What I ultimately need to do is figure out a way to split the
code onto two separate lines and have the code continue to work and
read from the end of the first line and continue at the beginning of
the second. I hope this description helps. Thanks
Try this one

strSQL = "first part" & _
"Next part" & _
"And so on"
the _ must proceed with a space
the last line can't have a _

2solution
if this does not work
strSQL1= "First part"
strSQL2="Second part"
strSQL3="3"
strSQL4="4"
strSQL=strSQL1+strSQL2+strSQL3+strSQL4

Oct 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.