Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Continuation character in VB for Access? 1

Status
Not open for further replies.

gusbrunston

Programmer
Feb 27, 2001
1,234
US
[tt]
Hi:

I thought all one had to do to continue a statement to the next line in code for sub or function in Access was to end the first line with the underscore (_).

However, I get a "compile" error.

Would appreciate very much your help with this. Gus Brunston [glasses] An old PICKer, using Access2000
[tt]Want solutions you can understand?
Post understandable questions.
[/tt]
 
Gotta be " _", with a space first.

If that doesn't work, post some code here. It's sometimes tricky to get things to go right.

If you're breaking a line in the middle of a string, you have to do this
Call MsgBox("The quick brown fox jumped over " _
& "the lazy dog.", vbCritical, "History Lesson")

But if you're breaking between parameters, you don't want to concatenate, so...
Call MsgBox("The quick brown fox jumped over " _
& "the lazy dog.", _
vbCritical, "History Lesson")

Hope this helps.

Jeremy

=============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Hi, Jeremy:

Thanks for your attention to my question.

Tried the space in front, but still doesn't work. Here's some code, it works just fine, but I would like to learn how to divide those longer lines, like the SQL line in this:

[tt]Function calBalance()
'requires a reference to DAO 3.6
On Error GoTo Err1
Dim SQL As String, db As Database, RS As Recordset
Dim CurBB As Currency, CurDB As Currency
SQL = "SELECT [tblRegister].TransNumber, [tblRegister].DepAmt, [tblRegister].ChkAmt, [tblRegister].Balance FROM [tblRegister] ORDER BY [tblRegister].TransNumber"
Set db = CurrentDb()
Set RS = db.OpenRecordset(SQL, dbOpenDynaset)
If RS.RecordCount = 0 Then
RS.Close
GoTo Exit1
End If
CurBB = 0
RS.Edit
RS!Balance = CurBB - RS!ChkAmt + RS!DepAmt
RS.Update
CurDB = RS!Balance
RS.MoveNext
Do Until RS.EOF
RS.Edit
RS!Balance = CurDB - RS!ChkAmt + RS!DepAmt
RS.Update
CurDB = RS!Balance
RS.MoveNext
Loop
RS.Close
db.Close
Exit1:
Exit Function
Err1:
GoTo Exit1
End Function[/tt]

I'm sure I read somewhere that it's just necessary to end the first line with an underscore, but maybe that was in a VB manual.

Appreciate any further suggestions.


Gus Brunston [glasses] An old PICKer, using Access2000
[tt]Want solutions you can understand?
Post understandable questions.
[/tt]
 
SQL = "SELECT [tblRegister].TransNumber, " _
& "[tblRegister].DepAmt, [tblRegister].ChkAmt, " _
& "[tblRegister].Balance FROM [tblRegister] ORDER BY " _
& "[tblRegister].TransNumber" =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
[tt]
Thank you very much![/tt] Gus Brunston [glasses] An old PICKer, using Access2000
[tt]Want solutions you can understand?
Post understandable questions.
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top