shankbanta
Technical User
I need with making an addendum to some code. This code was created by someone else and being the novice that I am, I know what I want it to do, but am unsure of the code. This is how it currently stands:
Private Sub Download_AS400_Click()
On Error GoTo Err_Download_AS400_Click
DoCmd.SetWarnings False
DoCmd.OpenQuery "Append AS/400"
Me.Refresh
DoCmd.SetWarnings True
Me.RecordSource = "select * from [BTD1];"
Dim R As Recordset
Set R = Me.RecordsetClone
R.FindFirst "[JobNum] = " & Chr(34) _
& Me![JobAS400] & Chr(34)
Me.Bookmark = R.Bookmark
[FindJob] = [JobAS400]
[FindBan] = [BanCode]
[BanCovQty] = 0
If [JobNum] = 0 Then
SendKeys "{ESC}"
End If
DoCmd.GoToControl "BinderOp"
Exit_Download_AS400_Click:
Exit Sub
Err_Download_AS400_Click:
MsgBox Err.Description
Resume Exit_Download_AS400_Click
End Sub
I the [JonNum] is not found in the AS400 database I get the following error:
"Update or CancelUpdate wihtou AddNew or Edit"
So I think I need an If statement for when the job code is not found on the AS400. When the number is not found, I need to make a new record in the BTD1 database.
If [FindJob] Not Equal [JobAS400]
Then AddNew
Thanks for all help.
Private Sub Download_AS400_Click()
On Error GoTo Err_Download_AS400_Click
DoCmd.SetWarnings False
DoCmd.OpenQuery "Append AS/400"
Me.Refresh
DoCmd.SetWarnings True
Me.RecordSource = "select * from [BTD1];"
Dim R As Recordset
Set R = Me.RecordsetClone
R.FindFirst "[JobNum] = " & Chr(34) _
& Me![JobAS400] & Chr(34)
Me.Bookmark = R.Bookmark
[FindJob] = [JobAS400]
[FindBan] = [BanCode]
[BanCovQty] = 0
If [JobNum] = 0 Then
SendKeys "{ESC}"
End If
DoCmd.GoToControl "BinderOp"
Exit_Download_AS400_Click:
Exit Sub
Err_Download_AS400_Click:
MsgBox Err.Description
Resume Exit_Download_AS400_Click
End Sub
I the [JonNum] is not found in the AS400 database I get the following error:
"Update or CancelUpdate wihtou AddNew or Edit"
So I think I need an If statement for when the job code is not found on the AS400. When the number is not found, I need to make a new record in the BTD1 database.
If [FindJob] Not Equal [JobAS400]
Then AddNew
Thanks for all help.