Netgroover
New member
- Local time
- Today, 13:04
- Joined
- Jul 4, 2014
- Messages
- 9
I wrote a macro and converted to VBA in Access/Office365, and I run this routine nightly. A few months ago it started crashing a few times a week with the error "the recordset is not updatable". If I debug and set the next statement at the line it crashed, then select continue, the routine finishes just fine.
I must stress that I'm an amateur Access user, but I would love to solve this problem so I don't have to manually intervene in what is an automatic routine most of the time. Any guidance greatly appreciated!
Here is where the line where the code sometimes crashes:
DoCmd.OpenQuery "Valid Reservations", acViewNormal, acEdit
In Debug I restart on the next line (the query table is open), and Continue here:
DoCmd.Save acQuery, "Valid Reservations"
DoCmd.RunSavedImportExport "Export-Valid Reservations"
Below is SQL view of the Query:
SELECT in_res.guestnum, in_res.level, in_res.resno, in_res.package, rate_codes.Pkg AS RATEPKG, Round([SUBTOTAL]/[NIGHTS],2) AS AVG_RATE, room_rates.RAK, [AVG_RATE]/[RAK] AS PCT_OF_RAK, in_res.arrival, in_res.depart, in_res.unit, Left([unit],1) AS PROP, in_res.anum, in_res.cnum, in_res.onum, IIf([ANUM]>2,[ANUM]-2+[ONUM],[ONUM]) AS XTRA, in_res.group, in_res.nights, in_res.booking, in_res.cancel, in_res.subtotal, in_res.rnotes, in_res.anotes, in_res.hnotes, in_res.op, in_res.name, in_res.rsource, [arrival]-[booking] AS LEAD, Month([BOOKING]) AS BOOK_MO, Year([BOOKING]) AS BOOK_YR, Month([ARRIVAL]) AS ARR_MO, Year([ARRIVAL]) AS ARR_YR, in_guest.added, Date()-[depart] AS SINCE_DEP, [noemail] & [bademadd] AS Exclude, IIf([added]<[booking],"PG","New") AS Prev_Gst, in_user_prop.homeprop, in_guest.stays, in_guest.nites, in_guest.lststay, in_guest.lstunit, in_email.email, in_guest.city, in_guest.state, in_res.rcorp
FROM ((((in_res LEFT JOIN in_guest ON in_res.guestnum = in_guest.guestnum) LEFT JOIN in_email ON in_guest.guestnum = in_email.guestnum) LEFT JOIN rate_codes ON in_res.package = rate_codes.OldPkg) LEFT JOIN room_rates ON in_res.unit = room_rates.ROOM) LEFT JOIN in_user_prop ON in_res.op = in_user_prop.USRCODE
WHERE (((in_res.level)<>"xxx" And (in_res.level)<>"OOO" And (in_res.level)<>"C/L") AND ((in_res.package)<>"COMP") AND ((Left([unit],1))<>"S") AND ((in_res.nights)>0) AND (([guar] & [level])<>"NNEW" And ([guar] & [level])<>"NCAN"))
ORDER BY in_res.booking DESC;
I must stress that I'm an amateur Access user, but I would love to solve this problem so I don't have to manually intervene in what is an automatic routine most of the time. Any guidance greatly appreciated!
Here is where the line where the code sometimes crashes:
DoCmd.OpenQuery "Valid Reservations", acViewNormal, acEdit
In Debug I restart on the next line (the query table is open), and Continue here:
DoCmd.Save acQuery, "Valid Reservations"
DoCmd.RunSavedImportExport "Export-Valid Reservations"
Below is SQL view of the Query:
SELECT in_res.guestnum, in_res.level, in_res.resno, in_res.package, rate_codes.Pkg AS RATEPKG, Round([SUBTOTAL]/[NIGHTS],2) AS AVG_RATE, room_rates.RAK, [AVG_RATE]/[RAK] AS PCT_OF_RAK, in_res.arrival, in_res.depart, in_res.unit, Left([unit],1) AS PROP, in_res.anum, in_res.cnum, in_res.onum, IIf([ANUM]>2,[ANUM]-2+[ONUM],[ONUM]) AS XTRA, in_res.group, in_res.nights, in_res.booking, in_res.cancel, in_res.subtotal, in_res.rnotes, in_res.anotes, in_res.hnotes, in_res.op, in_res.name, in_res.rsource, [arrival]-[booking] AS LEAD, Month([BOOKING]) AS BOOK_MO, Year([BOOKING]) AS BOOK_YR, Month([ARRIVAL]) AS ARR_MO, Year([ARRIVAL]) AS ARR_YR, in_guest.added, Date()-[depart] AS SINCE_DEP, [noemail] & [bademadd] AS Exclude, IIf([added]<[booking],"PG","New") AS Prev_Gst, in_user_prop.homeprop, in_guest.stays, in_guest.nites, in_guest.lststay, in_guest.lstunit, in_email.email, in_guest.city, in_guest.state, in_res.rcorp
FROM ((((in_res LEFT JOIN in_guest ON in_res.guestnum = in_guest.guestnum) LEFT JOIN in_email ON in_guest.guestnum = in_email.guestnum) LEFT JOIN rate_codes ON in_res.package = rate_codes.OldPkg) LEFT JOIN room_rates ON in_res.unit = room_rates.ROOM) LEFT JOIN in_user_prop ON in_res.op = in_user_prop.USRCODE
WHERE (((in_res.level)<>"xxx" And (in_res.level)<>"OOO" And (in_res.level)<>"C/L") AND ((in_res.package)<>"COMP") AND ((Left([unit],1))<>"S") AND ((in_res.nights)>0) AND (([guar] & [level])<>"NNEW" And ([guar] & [level])<>"NCAN"))
ORDER BY in_res.booking DESC;