| Chat with a LIVE Microsoft
Access Expert! |
||||
|
||||
|
#1
|
||||
|
||||
|
combo inside a listbox
hi.. basic table layout..
http://www.londonheathrowcars.com/db_tables.jpg have a query that displays jobs with no drivers.. http://www.londonheathrowcars.com/nodriver_qry.jpg i have seen that combos can be placed in listboxes.. i want the following form that will allow my user to set a driver to each job in the listbox.. so the combo on the right will be present on every row in the listbox.. and if a driver is chosen.. the driverid value is saved.. http://www.londonheathrowcars.com/nodriver_frm.jpg how can i do this? |
| Sponsored Links |
|
#2
|
||||
|
||||
|
A combo in a listbox? That's news to me. Never seen one. Are you sure it wasn't a subform made to look like a listbox?
__________________
Thanks, Bob Larson Free samples, tools and tutorials (including Auto Frontend Update Enabling Tool) "Have you tried turning it off and on again?" |
|
#3
|
|||
|
|||
|
Hi antonyx,
First, the combobox is not inside the listbox. It’s on top of the listbox. Judging from the query, the listbox on the left is using this query. The listbox on the right using the table called “Driver”. What you are asking is called a listbox search or listbox to listbox. The use of combobox is useless is this case. Unless you want to filter the right listbox but it’s unnecessary. The right listbox, you’ll need to determine the Multi Select property type ‘None’, ‘Simple’ or ‘Extended’. The code created will be base on that. You can leave the left listbox Row Source empty if you want to. Normally, you use the OnClick event of the right listbox to filter the left listbox. Something likes this for a single record filtering. Code:
Me.LeftListBox.RowSource = “SELECT jobdate,jobfrom,jobto,fkdriverid FROM job WHERE fkdriverid = “ & Me.RightListBox.Column(0) This code will repopulate the left listbox Row source with the filtered SQL syntax. Quote:
|
|
#4
|
||||
|
||||
|
ok.. yes i have just realised the example i am talking about is not a combo in a listbox.. it looks as if it is.. but really it is loads of combos next to each other..
here is that picture.. http://www.londonheathrowcars.com/dingding.jpg the form i want is a review and edit form.. the database lists the records that have no drivers and my user allocates a driver to each of these records.. so it would work like this.. http://www.londonheathrowcars.com/dingding2.jpg this is why i was saying i need a combo on each row of records that have no drivers.. then the user can literally go through the list of records.. and just choose drivers for all of them.. save it.. and hey presto.. all the records with no drivers now have drivers.. does this make more sense? |
|
#5
|
|||
|
|||
|
It does, but I think that you will need to get a bit more complex yet
![]() I would use two listboxes, the first for the jobs with no driver, but there should really be a time slot built in as I assume that your drivers do more than one run a day!. The second list box with the drivers would need to filter dynamicaly when a job is selected in the first listbox, again the drivers need time slots so that they can handle more than one job per day. when you filter you can then just select drivers not already allocated to a job at the same time. you then need a button so that once you have paired a job and driver by selecting one of each in the listboxes you can update the job table and remove them from the choices. does that make sense? peter |
|
#6
|
||||
|
||||
|
i think it does make sense.. this form will be a daily form..
it will display all the jobs for a single day.. and my user will allocate drivers to all the jobs on a select day that dont already have a driver registered to them... let me make the new form.. and show you my interpretation of your idea |
|
#7
|
||||
|
||||
|
ok..here is what the form will look like..
http://www.londonheathrowcars.com/prvw1.jpg and are you saying that when items are highlighted in each listbox.. and the user presses the button.. like so.. http://www.londonheathrowcars.com/prvw2.jpg then jimmy will be allocated to the Twickenham 2 Stratford job.. the job listbox will be requeried and the Twickenham 2 Stratford job will be removed from the list..?? if this is the way to do it.. what do i need to do next.. i presume i would need some code on my button.. like the following.. Code:
onclick.. For all jobs selected in lstjobs set lstdriver.value as fkdriverid lstjobs.Requery |
|
#8
|
|||
|
|||
|
on the right track,but easier to show than tell LOL
This really needs to have a filtering system for the drivers as well though, so that only available drivers are offered. Peter |
|
#9
|
||||
|
||||
|
thats great..
i think the remove driver may come in handy also.. the problem is when you try to remove 2 drivers in a row.. it doesnt let you.. did you notice that? |
|
#10
|
|||
|
|||
|
nope, I will have a look now though
|
|
#11
|
|||
|
|||
|
try changing its code to
Code:
Private Sub Command7_Click()
Dim strSql As String
If Nz(Me.[List5], -1) = -1 Then
MsgBox "Please select driver to delete", vbExclamation
Exit Sub
End If
strSql = "UPDATE tblJobs SET tblJobs.driverID = 0 WHERE (((tblJobs.JobID)= " & Me.[List5] & "));"
DoCmd.SetWarnings False
DoCmd.RunSQL strSql
DoCmd.SetWarnings True
Me.List0.Requery
Me.List5.Requery
Me.List5 = -1
End Sub
but it will do to demoPeter |
|
#12
|
||||
|
||||
|
thanks peter.. if you ever come through heathrow give me a pm and ill arrange a spanking new e-class for ya.
|
|
#13
|
|||
|
|||
|
Hi antonyx,
This is a continuous form with mutli comboboxes and it's on the Detail section. The three comboboxes on top of the detail section is in the Form Header. I hope Peter sample can demostrat the workings of a combobox in a continuous form. If not, look at the Sample at Ken Snell site. Here It's the sample from Pat HartMan. Quote:
|
|
#14
|
||||
|
||||
|
thank you joe.. that db may prove to be very useful to me in the future..
if i may ask one last favour regarding this form Peter.. (Batman) basically i want to create a form that deals specifically with one day.. my user will allocate drivers to the pre-bookings at the end of the day.. (which they can do using the form you kindly created for me..) and they will also have to enter the live jobs taken during the day.. the form I already had.. when it opens a message box appears and asks for the jobdate.. they enter a date.. and this date is saved as the date tag.. and each record they enter in that form automatically is set for that date.. you will see what i mean if you open this db.. anyway.. the last alteration i need is if possible.. when the form loads.. my calendar form loads.. the user chooses a date.. presses ok... and THAT date automatically is the date for the nodriver query listbox and also the date tag.. i think you will see what i mean if you open the db.. this will be the last request on this problem.. thank you for taking the time to listen to my issues.. my company is ever grateful.. |
|
#15
|
||||
|
||||
|
let me describe the issue in words so maybe someone can see the solution from the code..
when my form opens.. a message appears and prompts my user to enter a date.. (txtjobdate is the first control in the tab index..) Code:
Private Sub txtjobdate_GotFocus()
Dim dteFormDate As Date
If Me.txtjobdate.Text = "" Then
dteFormDate = CDate(InputBox("Enter the date:", "Date Entry"))
Me.txtjobdate.SetFocus
Me.txtjobdate.Text = dteFormDate
Me.txtjobtime.SetFocus
Else
Me.txtjobtime.SetFocus
End If
End Sub
Code:
Private Sub txtjobdate_AfterUpdate() Me!txtjobdate.Tag = Me!txtjobdate.Value Me.txtjobtime.SetFocus End Sub Private Sub Form_Current() Me.txtjobdate = Me.txtjobdate.Tag End Sub at the moment i have a listbox on the same form that lists jobs with no drivers allocated to them.. driverid=0.. the listbox uses a rowsource of the following.. Code:
SELECT tblJob.JobRef, tblJob.JobDate, tblJob.JobTime FROM tblJob WHERE (((tblJob.fkDriverID)=0)); Code:
SELECT tblJob.JobRef, tblJob.JobDate, tblJob.JobTime FROM tblJob WHERE (((tblJob.fkDriverID)=0)) AND ((tblJob.JobDate = dteFormDate)); so how can i alter this scenario to populate the lisbox after the date has been gathered from the message box.?? |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ListBox Combo | krinku | Forms | 0 | 05-30-2006 06:02 PM |
| Continuous Subform with Combo Boxes | Lynn_AccessUser | Forms | 3 | 01-29-2004 01:53 PM |
| populating a listbox from a combo box selection | alexi | Forms | 10 | 08-27-2003 10:40 PM |
| Combo and listbox values | dc_sc | Forms | 7 | 07-20-2003 06:26 AM |
| Updating Table With Dummy Combo Box | kevsim | Forms | 0 | 08-14-2002 02:07 AM |