VB Line too long

mr_sd

Registered User.
Local time
Today, 19:29
Joined
May 11, 2004
Messages
24
Hi, I am modifying a database which was written by someone else.

The database it used to take bookings from customers.

The booking form saves to the table tbl_(dump)Partybookings

The contents of this table are then moved to tbl_Partybookings and the dump table entry deleted.

It uses this VB Code:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
SQLStr = "INSERT INTO tbl_Partybookings ( [Date], Title, PartyName.....etc
SQLSrt = SQLStr & " SELECT [tbl_(dump)PartyBookings].Date, [tbl_(dump)PartyBookings.Title....etc

The problem is that the SELECT line is too long and I need to add more fields to be copied.

Being a bit of a novice, is there an easy way to carry this onto the next line or simplify the above code.

Thanks,
Rich.
 
A space followed by an underscore are line continuation symbols in VBA. Here's the first few of lines of a sub to illustrate:
Code:
  CurrentDb.Execute "INSERT INTO Tbl_AR_detail " & _
                    "( AR_key, Detail_type, Description, Order_num, Reservation_num, " & _
                    " Requestor, Quantity, Amount, Ext_amount )" & _
                    " SELECT Tbl_AR_master.AR_key, 'R', " & _
Note that you don't need to repeat your variable, like:

SQLSrt = SQLStr &

but watch your spaces, as it's real easy to end up without one, like

SELECT BlahFROM ...
 
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

That line is also defunct. Replace it with:

Code:
DoCmd.RunCommand acCmdSaveRecord
 

Users who are viewing this thread

Back
Top Bottom