Line Continuation - Access 2K

  • Thread starter Thread starter Leonard Priestley
  • Start date Start date
L

Leonard Priestley

Some lines in my code are rather long. I have seen examples of Access Code
where the line has been broken, apparently by a space and underscore,
enabling it to be carried on on the next line. I can't get this to work for
me, and I can't find a reference to it in the help files. Can anyone help
please.

Leonard Priestley
 
You have to break the line at a keyword.....

So,

strMsg = strField + " does not have data." & vbCrLf & _
"You must enter a value for this Field?"

msgbox strMsg

The above shows how to do a multi line string....

DoCmd.TransferSpreadsheet acImport, , "InputTest", _
"C:\Documents and Settings\Albert\Desktop\palmex.xls", True, "A1:o10"

or, you ccould break before the comma

DoCmd.TransferSpreadsheet acImport, , "InputTest" _
, "C:\Documents and Settings\Albert\Desktop\palmex.xls", True, "A1:o10"
 
What you used (space + underscore) should work fine except you need to make
sure that you don't include it in a explicit string value.

For example:

MsgBox "This is an iccorect way to use _
as the continuation code is embedded in a String."

MsgBox "This is the correct way to use " & _
" the continuation code, i.e. outsire the explicit String value."
 
Albert,

Thank you for your answer. I must be missing something however, because I
can't apply the line continuation to this line of code:

Me.RecordSource = "SELECT tblEquipmentType.EquipmentTypeID,
tblDescription.Description, tblEquipmentType.Model,
tblManufacturer.Manufacturer, tblEquipmentType.CommonName,
tblEquipmentType.GroupID, tblGroup.Group,
tblEquipmentType.VerificationProtocol, tblEquipmentType.TimeAllocated,
tblEquipmentType.ElectricalClass, tblEquipmentNotePath.EquipmentNotePath,
tblPhotopath.Photopath FROM tblPhotopath INNER JOIN (tblManufacturer INNER
JOIN (tblGroup INNER JOIN (tblEquipmentNotePath INNER JOIN (tblDescription
INNER JOIN tblEquipmentType ON tblDescription.DescriptionID =
tblEquipmentType.DescriptionID) ON tblEquipmentNotePath.EquipmentNotePathID
= tblEquipmentType.EquipmentNotePathID) ON tblGroup.GroupID =
tblEquipmentType.GroupID) ON tblManufacturer.ManufacturerID =
tblEquipmentType.ManufacturerID) ON tblPhotopath.PhotopathID =
tblEquipmentType.PhotopathID WHERE tblEquipmentType.CommonName = '" &
Me![cboCommonName] & "' ORDER BY tblDescription.Description,
tblEquipmentType.Model"

Obviously it's broken into lines in the email, but in Access it is one long
line, and I guess you can see why I would like to break it up. I have tried
applying space+underscore at places like "INNER JOIN", and also before
commas, but with no success.

Leonard Priestley
 
Try:

Me.RecordSource = "SELECT ET.EquipmentTypeID, D.Description, ET.Model, " & _
" M.Manufacturer, ET.CommonName, ET.GroupID, G.Group, " & _
" ET.VerificationProtocol, ET.TimeAllocated, ET.ElectricalClass, " & _
" ENP.EquipmentNotePath, PP.Photopath " & _
" FROM tblPhotopath AS PP " & _
" INNER JOIN (tblManufacturer AS M " & _
" INNER JOIN (tblGroup AS G " & _
" INNER JOIN (tblEquipmentNotePath AS ENP " & _
" INNER JOIN (tblDescription AS D " & _
" INNER JOIN tblEquipmentType AS ET " & _
" ON D.DescriptionID = ET.DescriptionID) " & _
" ON ENP.EquipmentNotePathID = ET.EquipmentNotePathID) " & _
" ON G.GroupID = ET.GroupID) " & _
" ON M.ManufacturerID = ET.ManufacturerID) " & _
" ON PP.PhotopathID = ET.PhotopathID " & _
" WHERE ET.CommonName = '" & Me![cboCommonName] & _
"' ORDER BY D.Description, ET.Model"

Note that I used aliases to shorten the Table names as above.
 
Oh I see now. Thank you for clarifying that.
Leonard

Van T. Dinh said:
Try:

Me.RecordSource = "SELECT ET.EquipmentTypeID, D.Description, ET.Model, " & _
" M.Manufacturer, ET.CommonName, ET.GroupID, G.Group, " & _
" ET.VerificationProtocol, ET.TimeAllocated, ET.ElectricalClass, " & _
" ENP.EquipmentNotePath, PP.Photopath " & _
" FROM tblPhotopath AS PP " & _
" INNER JOIN (tblManufacturer AS M " & _
" INNER JOIN (tblGroup AS G " & _
" INNER JOIN (tblEquipmentNotePath AS ENP " & _
" INNER JOIN (tblDescription AS D " & _
" INNER JOIN tblEquipmentType AS ET " & _
" ON D.DescriptionID = ET.DescriptionID) " & _
" ON ENP.EquipmentNotePathID = ET.EquipmentNotePathID) " & _
" ON G.GroupID = ET.GroupID) " & _
" ON M.ManufacturerID = ET.ManufacturerID) " & _
" ON PP.PhotopathID = ET.PhotopathID " & _
" WHERE ET.CommonName = '" & Me![cboCommonName] & _
"' ORDER BY D.Description, ET.Model"

Note that I used aliases to shorten the Table names as above.

--
HTH
Van T. Dinh
MVP (Access)




Leonard Priestley said:
Albert,

Thank you for your answer. I must be missing something however, because I
can't apply the line continuation to this line of code:

Me.RecordSource = "SELECT tblEquipmentType.EquipmentTypeID,
tblDescription.Description, tblEquipmentType.Model,
tblManufacturer.Manufacturer, tblEquipmentType.CommonName,
tblEquipmentType.GroupID, tblGroup.Group,
tblEquipmentType.VerificationProtocol, tblEquipmentType.TimeAllocated,
tblEquipmentType.ElectricalClass, tblEquipmentNotePath.EquipmentNotePath,
tblPhotopath.Photopath FROM tblPhotopath INNER JOIN (tblManufacturer INNER
JOIN (tblGroup INNER JOIN (tblEquipmentNotePath INNER JOIN (tblDescription
INNER JOIN tblEquipmentType ON tblDescription.DescriptionID =
tblEquipmentType.DescriptionID) ON tblEquipmentNotePath.EquipmentNotePathID
= tblEquipmentType.EquipmentNotePathID) ON tblGroup.GroupID =
tblEquipmentType.GroupID) ON tblManufacturer.ManufacturerID =
tblEquipmentType.ManufacturerID) ON tblPhotopath.PhotopathID =
tblEquipmentType.PhotopathID WHERE tblEquipmentType.CommonName = '" &
Me![cboCommonName] & "' ORDER BY tblDescription.Description,
tblEquipmentType.Model"

Obviously it's broken into lines in the email, but in Access it is one long
line, and I guess you can see why I would like to break it up. I have tried
applying space+underscore at places like "INNER JOIN", and also before
commas, but with no success.

Leonard Priestley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top