Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

First In First Out

Good Day All

I am trying to create a FIFO (First In First Out) with a combo box in MS Access 2003.  When you select a name in a combo box that name automatically rotates to the bottom of the list in the combo box.  Does anyone have examples of coding on First In First Out, or suggest how this could be created?

Thanks
0
Beeyen
Asked:
Beeyen
  • 5
  • 2
  • 2
  • +3
1 Solution
 
peter57rCommented:
If you have a table of two columns, ID and Namefield you initially number them in the sequence you want them to appear in the combo.
So you rowsource orders then emtries by this field.

Then when you select a value from the combo, you run an update query to update that record in the source table, so that the ID is Max(id) +1.  Then requery the combo.

You could use an autonumber field as the id instead.  In that case you would append a new record with the name value and then delete the existing record.  
0
 
Jim P.Commented:
You would have an extra column on your names table like Lineup.

You make the query for your combo box
-------------------------------------
SELECT EmpName
FROM EmpTable
ORDER BY Lineup
-------------------------------------

Then your on click event would be something like
-------------------------------------
On_Click
'Do whatever else

Dim LineNum As String
DIM SQL as string

LineNum = DMax("Lineup", "EmpTable") + 1

SQL = "UPDATE EmpTable " & _
     "SET Lineup = " & LineNum " " & _
     "WHERE EmpName = '" & Me.ComboBox.Value & "'"

DOCMD.setwarnings false
docmd.runsql sql
DOCMD.setwarnings true
-------------------------------------
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
How are you filling this box now?

How are you ordering the names in this box now?

What happens to the other names in the box after you select a name? In other words, if I have this list:

Blue
Red
Green
Yellow

and I select "Green", what would the list look like afterward? What if I select Red?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BeeyenAuthor Commented:
Good Day jimpen:

Thank you for the quick response.

Ok, below is the property of the combo box I would like to make FIFO, could you suggest how I would set it up to get started?  


Control Source = ProductionAssigned
Name = Productionassignedname
Combo Box
Row Source Type: Table/Query
Row Source:
SELECT tblBenefitsEmployee.EmployeeID, tblBenefitsEmployee.LastName & ", " & [FirstName] AS Expr1 FROM tblBenefitsEmployee ORDER BY tblBenefitsEmployee.LastName & ", " & [FirstName], tblBenefitsEmployee.FirstName WITH OWNERACCESS OPTION;

Bound Column: 1
Column Count: 2
Column Widths: 0;2;2
0
 
sirtamCommented:
Hi.

Make a new module for the FIFO and insert the following code.

It is a simple FIFO used with Strings, but can be changed to be used with whatever you want.
Option Compare Database
Option Explicit
 
'
' A FIFO (First In First Out) buffer.
'
Private vData As New Collection
    'vData = New Collection
 
'
'  Adds an item to the FIFO
'
Public Sub Push(v As String)
   If vData.count = 0 Then
      vData.Add v
   Else
      vData.Add v, , , vData.count
   End If
End Sub
 
'
'  Clears all items from the FIFO
'
Public Sub Clear()
   Set vData = New Collection
End Sub
 
'
' Returns the number of items in the FIFO
'
Public Property Get count() As Integer
   count = vData.count
End Property
 
 
 
'
'  Returns an item from the FIFO
'
Public Function Pop() As String
   If vData.count = 0 Then
      Pop = Null
   Else
      If VarType(vData(1)) = vbObject Then
         Pop = vData(1)
      Else
         Pop = vData(1)
      End If
      vData.Remove 1
   End If
End Function
 
'
'  Returns the next item in the FIFO but does
'  not remove it from the FIFO
'
Public Function Peek() As String
   If vData.count = 0 Then
      Peek = Null
   Else
      If VarType(vData(1)) = vbObject Then
         Peek = vData(1)
      Else
         Peek = vData(1)
      End If
   End If
End Function

Open in new window

0
 
sirtamCommented:
Note: This code is taken (but a bit edited) from the following thread:

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_10067783.html
0
 
Jim P.Commented:
You would have to still add the Lineup (or whatever column) to the tblBenefitsEmployee. But from there it would look something like this.

I assume that you have a button that does the actual assignment or whatever else.

SELECT tblBenefitsEmployee.EmployeeID, tblBenefitsEmployee.LastName & ", " & [FirstName] AS Expr1 FROM tblBenefitsEmployee ORDER BY tblBenefitsEmployee.LastName & ", " & [FirstName], tblBenefitsEmployee.FirstName
ORDER BY Lineup
 WITH OWNERACCESS OPTION;
-------------------------------------------
 
On_Click
'Do whatever else
 
Dim LineNum As String
DIM SQL as string
 
LineNum = DMax("Lineup", "tblBenefitsEmployee") + 1
 
SQL = "UPDATE tblBenefitsEmployee " & _
     "SET Lineup = " & LineNum " " & _
     "WHERE EmployeeID= '" & Me.Productionassignedname.Value & "'"
 
DOCMD.setwarnings false
docmd.runsql sql
DOCMD.setwarnings true
 
Me.Productionassignedname.Requery
 
End Sub

Open in new window

0
 
GRayLCommented:
Maybe I'm naive, but what's this got to do with FIFO?
0
 
Jim P.Commented:
From what I can tell -- the next employee in line gets the next job.

So when he hits the drop down list in the combo box, the next employee in the list gets the job. Then the next one gets the next and so on. He's wanting to avoid slamming one person multiple times.

It might not be true FIFO, but more of get an ordered cycle down.
0
 
Jim P.Commented:
Just wondering if you have done anything with this?
0
 
BeeyenAuthor Commented:
Good Day Mr Jimpen

I apoligize for the delay, I was called out of town on an emergency and have restarted my project.  I have reviewed your suggestion which is what I am trying to accomplish.  I will give your coding suggestion a try and let you know the if I have further questions, if not I will just accept this as the solution.

Thanks
0
 
Jim P.Commented:
Glad to be of assistance. May all your days get brighter and brighter.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now