Ok powerpro . . . . .
Now were playing with power! [blue]
randy700[/blue] is right on target. [blue]You'll need an additional field for sorting.[/blue] Before continuing with this, [purple]
backup the data base so you can come back to square one if necessary[/purple] ([blue]I doubt you'll have to[/blue]). Following is an outline of what your gonna do:
[ol][li]Add the sort field to the table.[/li]
[li]Update the sortfield for existing records! (via code)[/li]
[li]Setup a query for the forms RecordSource which includes the sort field.[/li]
[li]Add code for updating the sort field when new equipment is added.[/li]
[li]Setup a query for the Reports RecordSource which includes the sort field.[/li][/ol]
Here we go:
1) Add an additional field to the table with the following properties:
[blue]Field Name [purple]
SortTag[/purple]
Data Type [purple]
Number[/purple]
Field Size [purple]
Integer[/purple][/blue]
Save/close the table.
2) Update existing records: In a new or existing form add a [blue]Command Button[/blue]. In the On Click event, copy/paste the following code ([blue]
you[/blue] substitute the proper tablename in [purple]
purple[/purple] . . . be careful of spacing):
Code:
[blue] Dim n As Integer, SQL As String, typName As String
For n = 1 To 5
typName = Choose(n, "RPIE", "Pump", "EAID", "Readiness", "Unassigned")
SQL = "UPDATE [purple][b]TableName[/b][/purple] " & _
"SET tagSort = " & n & " " & _
"WHERE EquipType = '" & typName & "';"
DoCmd.RunSQL SQL
Next[/blue]
Open the form, hit the button and verify the table has been updated.
3)Setup a query to return all the fields you currently have int form. Include the [purple]
SortTag[/purple]. Set you sorting approiately. [blue]
Remember sorting priority is from left to right.[/blue] I suggest a sort order of [purple]
TagSort - serial number[/purple], so you'll have to position [purple]
TagSort[/purple] ahead of [purple]
serial number[/purple].
4) Updating TagSort for added equipment: In the After Update event of [purple]
Type[/purple] (the combobox), copy/paste the following code ([blue]
you[/blue] substitute the proper combobox name in [purple]
purple[/purple]):
Code:
[blue] Dim n As Integer, typName As String
For n = 1 To 5
typName = Choose(n, "RPIE", "Pump", "EAID", "Readiness", "Unassigned")
If Me![purple][b]ComboboxName[/b][/purple].Column(1) = typName Then
Me!TagSort = n
Exit For
End If
Next[/blue]
I don't know the structure of you combobox, so you may have to play a little with [blue]
Column([purple]?[/purple])[/blue].
5) For the Report query, do the same as in [purple]
3)[/purple] only for the report.
Thats it . . . . give it a whirl & let me know . . . .
See Ya! . . . . . .