Two suggestions:
Don't state "it didn't work" without some statement of what your results were. Did you get an error? Were there no records added? Did record get added but they weren't as expected?
Add a debug.print to your code so you can easily see what SQL is being run. I rarely if ever Execute until I have used:
Debug.Print strSQL
' uncomment the next line once you have reviewed the strSQL
' CurrentDb.Execute strSQL, dbFailOnError
Duane Hookom, MVP
MS Access
To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Sat, 31 Oct 2015 08:06:31 +0800
Subject: Re: [MS_AccessPros] Run an append query automatically
Don't state "it didn't work" without some statement of what your results were. Did you get an error? Were there no records added? Did record get added but they weren't as expected?
Add a debug.print to your code so you can easily see what SQL is being run. I rarely if ever Execute until I have used:
Debug.Print strSQL
' uncomment the next line once you have reviewed the strSQL
' CurrentDb.Execute strSQL, dbFailOnError
Duane Hookom, MVP
MS Access
To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Sat, 31 Oct 2015 08:06:31 +0800
Subject: Re: [MS_AccessPros] Run an append query automatically
By the way, I did something like this, it didn't work out. What's wrong with my code? Thanks.
Dim strSQL As String
If IsNull(ELookup("PartItineraryCityTourBookingRoomID", "tblPartItineraryCityTourBookingRoom", "PartItineraryCityTourID=" & PartItineraryCityTourID)) Then
strSQL = "INSERT INTO tblPartItineraryCityTourBookingRoom (RoomTypeID, NumberOfRooms,)" & _
"SELECT tblGroupBookingRoom.RoomTypeID, tblGroupBookingRoom.NumberOfRooms" & _
"FROM tblGroupBookingRoom WHERE GroupBookingID=Me.Parent.GroupBookingID" & "," & PartItineraryCityTourID
CurrentDb.Execute strSQL, dbFailOnError
End If
If IsNull(ELookup("PartItineraryCityTourBookingRoomID", "tblPartItineraryCityTourBookingRoom", "PartItineraryCityTourID=" & PartItineraryCityTourID)) Then
strSQL = "INSERT INTO tblPartItineraryCityTourBookingRoom (RoomTypeID, NumberOfRooms,)" & _
"SELECT tblGroupBookingRoom.RoomTypeID, tblGroupBookingRoom.NumberOfRooms" & _
"FROM tblGroupBookingRoom WHERE GroupBookingID=Me.Parent.GroupBookingID" & "," & PartItineraryCityTourID
CurrentDb.Execute strSQL, dbFailOnError
End If
Regards,
Kevin Zhao
Date: 2015-10-31 06:57Subject: [MS_AccessPros] Run an append query automatically
Dear All,Is that possible to click on a command button run an append query automatically without pop up windows. For example:source table: tblBookingBookingID Roomtype NumberOfRoomsDestination table: tblCityRoomBookingCityRoomBookingID CityTourID RoomType NumberOfRoomsBy cliecking on a command button on the frmCityTour, I want to append "RoomType, NumberOfRoom" into tblCityRoomBooking, and I hope the "CityTourID" will be filled according to "CityTourID" from frmCityTour.Can this be done? Thanks.Best Regards,Kevin
Regards,Kevin Zhao
__._,_.___
Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
.
__,_._,___
Tidak ada komentar:
Posting Komentar