Hey Everyone, in need of your vba programming expertise!
Have the following code thus far and know it's a complete mess. Basically what I am trying to accomplish for my cmdLOOKUP_Click button to search for a specific Part Number and Location, which does the following:
1.) Validate whether the Part Number input exists from tbl PSPLOCB
2.) If the Part exists, then has the Location input already been assigned?
3.) If the Location has not been assign, assign it and update tbl PSPLOCB
4.) If the Location has been assigned to another Part Number, indicate location is not valid
Any assistance is very much appreciated. Thanks!
Private Sub cmdLOOKUP_Click()
'Open Recordset
Dim db As DAO.Database
Set db = CurrentDb
Dim rst As DAO.Recordset
Set rst = db.OpenRecordset("PSPLOCB")
'Loop
Do While Not rstPSPLOCB.EOF
rstPSPLOCB.MoveNext
Loop
'Add Records
With rst
.AddNew
!MyField1 = "PARTLB"
!MyField2 = "SLOCLB"
.Update
End With
'Find Records
.FindFirst “PARTLB = “ & Me!PARTLB
'Update Records
With rst
.FindFirst “PARTLB = “ & Me!PARTLB
If Not .NoMatch Then
.Edit
!PARTLB = 1
.Update
End If
End With
End Sub
Have the following code thus far and know it's a complete mess. Basically what I am trying to accomplish for my cmdLOOKUP_Click button to search for a specific Part Number and Location, which does the following:
1.) Validate whether the Part Number input exists from tbl PSPLOCB
2.) If the Part exists, then has the Location input already been assigned?
3.) If the Location has not been assign, assign it and update tbl PSPLOCB
4.) If the Location has been assigned to another Part Number, indicate location is not valid
Any assistance is very much appreciated. Thanks!
Private Sub cmdLOOKUP_Click()
'Open Recordset
Dim db As DAO.Database
Set db = CurrentDb
Dim rst As DAO.Recordset
Set rst = db.OpenRecordset("PSPLOCB")
'Loop
Do While Not rstPSPLOCB.EOF
rstPSPLOCB.MoveNext
Loop
'Add Records
With rst
.AddNew
!MyField1 = "PARTLB"
!MyField2 = "SLOCLB"
.Update
End With
'Find Records
.FindFirst “PARTLB = “ & Me!PARTLB
'Update Records
With rst
.FindFirst “PARTLB = “ & Me!PARTLB
If Not .NoMatch Then
.Edit
!PARTLB = 1
.Update
End If
End With
End Sub