Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi! I am trying to look up a p

Status
Not open for further replies.

waldo7474

Technical User
Dec 30, 2002
38
US
Hi!
I am trying to look up a part number using a text box. If this part number is found, I would like to make a revision change (I would like to keep the old information). If it is not found, I would like to enter a new record.
So, now I have this set up to pull up the record, but it will write over the old information. I think this is due to the fact that I am "Finding Next". I would like to have the part number looked up, find the Unique identifier associated to it (this will fill in the subforms with the same unique identifier) and I can then change the revision. I have entered the code below:
Code:
Private Sub Text76_AfterUpdate()
    Dim rs As Object
        
    Set rs = Me.Recordset
    rs.FindFirst "[PartNumber] = """ & [Text76] & """"
Dim strPartID As String
strPartID = Me!PartID
DoCmd.GoToRecord , , acNewRec
Me!PartID = strPartID

Code:
DoCmd.GoToControl "Revision"
    Me.Revision.Locked = False
    Me.ECN.Locked = False
    
    If rs.NoMatch Then
        DoCmd.GoToRecord , , acNewRec
        strText76 = Me!Text76
        strPartNumber = Me!PartNumber
        Me!PartNumber = strText76
        DoCmd.GoToControl "Family"
        Me.Family.Locked = False
        Me.MultiplePages.Locked = False
        Me.DrawingSizeSheet1.Locked = False
        Me.DrawingSizeSheet2.Locked = False
        Me.DrawingSizeSheet3.Locked = False
        Me.Description.Locked = False
        Me.Revision.Locked = False
        Me.ECN.Locked = False
        Me.FirstUsedOn.Locked = False
        
    End If
    
End Sub

I hope this makes sense. I added the Go to New record thing (in red), while trying to use the PartID and when it ran it said that I cannot do this. I thought it might be a solution, but I just ended up with more problems. I do not know Visual Basic at all, I have self-adapted my code that I have.

Thank you in advance for any help that can be achieved.
Wally
 
You need to use the RecordsetClone. Try something like this:

Me.RecordsetClone.FindFirst "[PartNumber] = """ & [Text76] & """"
If (Me.RecordsetClone.NoMatch) Then
MsgBox "no match then add record"
Else
msgbox "found match. moving to that record"
Me.Recordset.Bookmark = Me.RecordsetClone.Bookmark
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top