hello again,
I'm in trouble again and need help, I have a query which has a Id of set and particular pieces for it. On the form that I've got user selects the Id of set and gets all the pieces which are in it. Each piece has its own report which is printed afterwards.
What I want to do, is to have a sort of running number which will be printed on the report (haven't done this piece yet) thus I want to save the Id_piece in a table with the autonumber filed (pk). As a result, will have a uniqe number on the report and can easily go back to particular piece.
Here is the code I came up with, I have a problem with loop and MoveNext
Any help would be appreciated
Private Sub RunNo_Click()
On Error GoTo Err_Save_Click
Dim dbs As Database
Dim qdf As QueryDef
Dim id As String
Dim i As Single
Dim Response, resp
Dim rstName As Recordset
Dim prm As Parameter
Set dbs = CurrentDb()
Set qdf = dbs.QueryDefs("INQ_BOM")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rstName = CurrentDb.OpenRecordset("TAB_MM_Autonumber", dbOpenDynaset)
Response = MsgBox("Do you want to pick that set?", vbYesNo, "Message")
If Response = 6 Then
DoCmd.OpenReport "Metric", acViewPreview
End If
resp = MsgBox("Was the document printed correctly?", vbYesNo, "Message")
If resp = 6 Then
Do While Not qdf.OpenRecordset.EOF
id = qdf.OpenRecordset.Fields("Id_piece")
rstName.AddNew
rstName.Fields("Id_seti") = id
rstName.Update
qdf.OpenRecordset.MoveNext
End If
Loop
rstName.Close
Exit_save_Click:
Exit Sub
Err_save_Click:
MsgBox Err.Description
Resume Exit_save_Click
End Sub
I'm in trouble again and need help, I have a query which has a Id of set and particular pieces for it. On the form that I've got user selects the Id of set and gets all the pieces which are in it. Each piece has its own report which is printed afterwards.
What I want to do, is to have a sort of running number which will be printed on the report (haven't done this piece yet) thus I want to save the Id_piece in a table with the autonumber filed (pk). As a result, will have a uniqe number on the report and can easily go back to particular piece.
Here is the code I came up with, I have a problem with loop and MoveNext
Any help would be appreciated
Private Sub RunNo_Click()
On Error GoTo Err_Save_Click
Dim dbs As Database
Dim qdf As QueryDef
Dim id As String
Dim i As Single
Dim Response, resp
Dim rstName As Recordset
Dim prm As Parameter
Set dbs = CurrentDb()
Set qdf = dbs.QueryDefs("INQ_BOM")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rstName = CurrentDb.OpenRecordset("TAB_MM_Autonumber", dbOpenDynaset)
Response = MsgBox("Do you want to pick that set?", vbYesNo, "Message")
If Response = 6 Then
DoCmd.OpenReport "Metric", acViewPreview
End If
resp = MsgBox("Was the document printed correctly?", vbYesNo, "Message")
If resp = 6 Then
Do While Not qdf.OpenRecordset.EOF
id = qdf.OpenRecordset.Fields("Id_piece")
rstName.AddNew
rstName.Fields("Id_seti") = id
rstName.Update
qdf.OpenRecordset.MoveNext
End If
Loop
rstName.Close
Exit_save_Click:
Exit Sub
Err_save_Click:
MsgBox Err.Description
Resume Exit_save_Click
End Sub