Apply renumbering to reults of a Query

G

Guest

I don't normally right code this is just a small project for a rather large
home office. So I am in way over my head...but willing to learn. Any help is
greatly appreciated.

The code works fine. I need to apply the renumbering to a certain set of
records that are selected through a form with a ComboBox then calling a
query. Can anyone show me how to apply the renumber to the result of my
query. The query works fine and the renumbering works fine, I just need to
apply the
Renumbering to the result of the query all in one step, preferably from
within the forms event procedure.

Here is the code for the Event Procedure which calls up the query:

Option Compare Database

Private Sub cboCabinet_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub cmdCancel_Click()
DoCmd.Close acForm, "renumberform1"
End Sub

Private Sub cmdEnter_Click()

If IsNull(cboCabinet) Then
MsgBox "You must choose a Cabinet."
Exit Sub
End If

DoCmd.OpenQuery "renumberquery1", acViewNormal, acEdit
DoCmd.Close acForm, "renumberform1"

End Sub

Private Sub Form_Load()

End Sub


Here is the Renumber code I am using:

Sub RenumberField()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim i As Integer
strSQL = "SELECT * FROM [Folder Labels] ORDER BY [Order]"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
rst.MoveFirst
i = 1
Do
rst.Edit
rst![Order] = i
rst.Update
rst.MoveNext
i = i + 2
Loop Until rst.EOF
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top