Minggu, 17 Januari 2016

Re: [MS_AccessPros] strSQL doesn't work

 

You are missing a space in front of the AND keyword in your ELookup:


" AND HotelID=" & Me.HotelID) 

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)



On Jan 17, 2016, at 10:04 AM, 'zhaoliqingoffice@163.com' zhaoliqingoffice@163.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:


John-
I tried all my best, but the send strSQLTwo doesn't work. Please have a look. Thanks in advance.

Private Sub Command74_Click()
On Error GoTo ErrHandle

Dim strSQL As String
Dim strSQLTwo As String



strSQL = "INSERT INTO tblHotelBooking (PartItineraryCityTourID, HotelID, CurrencyID, BookingStatusID) VALUES(" & Me.PartItineraryCityTourID & _
", " & Me.Parent.HotelID & ", " & ELookup("CurrencyID", "qryGetCurrencyByCountry", "CityID=" & Me.CityID) & ", " & 3 & ")"

Me.Requery

CurrentDb.Execute strSQL, dbFailOnError

        strSQLTwo = "INSERT INTO tblHotelBookingRoom ( RoomTypeID, NumberOfRooms, Budget, HotelBookingID ) " & _
            "SELECT tblPartItineraryCityTourRoom.RoomTypeID, tblPartItineraryCityTourRoom.NumberOfRooms, tblPartItineraryCityTourRoom.Budget, " & _
            ELookup("HotelBookingID", "tblHotelBooking", "PartItineraryCityTourID=" & PartItineraryCityTourID & "AND HotelID=" & Me.HotelID) & " AS HotelBookingID " & _
           "FROM tblPartItineraryCityTourRoom " & _
            "WHERE tblPartItineraryCityTourRoom.PartItineraryCityTourID = " & Me.PartItineraryCityTourID
        
CurrentDb.Execute strSQLTwo, dbFailOnError
        

Me.Parent.subManyRequestGroupForHotel.Requery
Me.Parent.subHotelBookingSelect.Requery



ErrExit:
    Exit Sub
    
ErrHandle:
    Resume ErrExit
End Sub


__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Poskan Komentar