hello,
 
I've a it of a head scratcher here. I've been going at it for a good while without avail!
 
I have a bookings database for ski chalets. There is a table tblBedSpace, and there are 4 fields being ID, chalet, roomnumber and bednumber. The idea is each guest gets placed in, for example, chalet bruyeres room 1 bed 2. Having each bedspace have a unique ID helps me in my systems to make sure that i don't double book any spaces.
 
I'm trying to create my main bookings form. A booking has a group of people all booked into different bedspaces
 
frmBookings has a subform called sfrmqryGuestBookings (which contains info on on the guests within that booking)
 
In this subform I have a field for the guestname (linked to a separate table called tblGuest) and a field for the bedspace.
 
I have put 2 unbound combo boxes on the subform, first to select chalet, next to select room number and these two put a WHERE clause into the SQL rowsource for the bedspace field so only the available beds are there to pick from (to save me scrolling through every possible bed in resort)
 
I've also put in some code so that the on current event of the subform removes the WHERE clause the bedspace back to having all bedspaces available. This makes all the bedspaces show (otherwise ones that are not in the current chalet don't show up)
 
Finally I've put some dlookups so that the unbound combo box shows the chalet name for that bedspace, again on the on current event for the subform.
 
It all works great when its viewed as a form. I want to view it as a datasheet, as then I can see all the guests in th booking at once.
 
The unbound combo for the chalet is repeated on each line for each guest booking. They all say the same thing, I guess as the are effectively the same box. I'd like them to show individually which chalet each guest is in.
 
My code so far:
 
	
	
	
		
 
Any ideas? I've been going some serious head scratching. I've been looking into looping through each record but this does not get away from the fact that in effect I have a column of the same unbound combo box.
 
All ideas on directions I should look into would be greatly appreciated! I'm pretty stuck at the moment. I've new to this VBA so apologies if it's a ally simple thing!
 
Many thanks,
 
Phil.
 I've a it of a head scratcher here. I've been going at it for a good while without avail!
I have a bookings database for ski chalets. There is a table tblBedSpace, and there are 4 fields being ID, chalet, roomnumber and bednumber. The idea is each guest gets placed in, for example, chalet bruyeres room 1 bed 2. Having each bedspace have a unique ID helps me in my systems to make sure that i don't double book any spaces.
I'm trying to create my main bookings form. A booking has a group of people all booked into different bedspaces
frmBookings has a subform called sfrmqryGuestBookings (which contains info on on the guests within that booking)
In this subform I have a field for the guestname (linked to a separate table called tblGuest) and a field for the bedspace.
I have put 2 unbound combo boxes on the subform, first to select chalet, next to select room number and these two put a WHERE clause into the SQL rowsource for the bedspace field so only the available beds are there to pick from (to save me scrolling through every possible bed in resort)
I've also put in some code so that the on current event of the subform removes the WHERE clause the bedspace back to having all bedspaces available. This makes all the bedspaces show (otherwise ones that are not in the current chalet don't show up)
Finally I've put some dlookups so that the unbound combo box shows the chalet name for that bedspace, again on the on current event for the subform.
It all works great when its viewed as a form. I want to view it as a datasheet, as then I can see all the guests in th booking at once.
The unbound combo for the chalet is repeated on each line for each guest booking. They all say the same thing, I guess as the are effectively the same box. I'd like them to show individually which chalet each guest is in.
My code so far:
		Code:
	
	
	Private Sub form_current()
bedspace.RowSource = "SELECT tblBedSpace.ID, [tblBedSpace].bednumber & ' (in ' & [tblChalet].chaletname & ' room ' & [tblBedSpace].roomnumber & ')' " & _
                          "FROM tblChalet INNER JOIN tblBedSpace ON tblChalet.ID = tblBedSpace.chalet " & _
                          "ORDER BY tblBedSpace.bednumber;"
cboRoomNumber = DLookup("roomnumber", "tblBedSpace", "[ID] = bedspace")
cboChalet = DLookup("chalet", "tblBedSpace", "[ID] = bedspace")
End Sub
Private Sub cboChalet_AfterUpdate()
cboRoomNumber.RowSource = "SELECT DISTINCT tblBedSpace.roomnumber " & _
                          "FROM tblBedSpace " & _
                          "WHERE (((tblBedSpace.chalet) = " & Me.cboChalet & ")) " & _
                          "ORDER BY tblBedSpace.roomnumber;"
End Sub
Private Sub cboRoomNumber_AfterUpdate()
bedspace.RowSource = "SELECT tblBedSpace.ID, [tblBedSpace].bednumber & ' (in ' & [tblChalet].chaletname & ' room ' & [tblBedSpace].roomnumber & ')' " & _
                          "FROM tblChalet INNER JOIN tblBedSpace ON tblChalet.ID = tblBedSpace.chalet " & _
                          "WHERE (((tblChalet.ID) = " & Me.cboChalet & ") And ((tblBedSpace.roomnumber) = " & Me.cboRoomNumber & ")) " & _
                          "ORDER BY tblBedSpace.bednumber;"
End Sub
	Any ideas? I've been going some serious head scratching. I've been looking into looping through each record but this does not get away from the fact that in effect I have a column of the same unbound combo box.
All ideas on directions I should look into would be greatly appreciated! I'm pretty stuck at the moment. I've new to this VBA so apologies if it's a ally simple thing!
Many thanks,
Phil.