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!

.findfirst

Status
Not open for further replies.

Ascentient

IS-IT--Management
Nov 4, 2002
267
I had the following code working correctly, but I am not sure what changed

Code:
.FindFirst "[UPC] = " & rsClone!UPC

It was previously giving me [UPC] = 123456 the code is not give me "[UPC] = 123456" when it does the search. Thus it failes because [UPC] in tblUPC is a number field.

Thoughts or suggestions as to what I have done to screw this up, and how to fix it?
 
im not sure i understand.

youre getting [UPC] = 123456 but you want "[UPC] = 123456" ??

is that correct?

-Pete
 
Snyperx3,
I am trying to get it back to [UPC] = 123456 as the field name is UPC and the field type in the table is number.
 
And instead it is giving you "[UPC] = '123456'"?
^^
or "[UPC] = 123456" ^^
^^ ^^
because ^^ that is a number and ^^ that is a string

-Pete
 
My mistake for not providing more information.

I want it to give me "[UPC] = 123456", which I am now getting. I just need to figure out why it's not giving me a match.

Ascent
 
OK, I can't seem to figure out why the following code fails on the .findfirst on the "cmdEdit" portion of the Select Case Statement. It always returns True for .NoMatch

Code:
   If Not IsNumeric(txtUpcCode) Then
      MsgBox "UPC Code is Alpha-Numeric. Please correct.", vbCritical, "SAVE FAILED"
      txtUpcCode.SetFocus
      Exit Sub
   End If
   Dim db As DAO.Database
   Dim rs As DAO.Recordset
   Set db = CurrentDb
   Set rs = db.OpenRecordset("tblUPC", dbOpenDynaset)
   Dim l1 As Variant
   l1 = txtUpcCode.OldValue
   With rs
      Select Case strCmdStatus
         Case "cmdAdd"
            .AddNew
            !Material = Me.cboMaterialCodeLookup
            !UPC = Trim(txtUpcCode)
            .Update
         Case "cmdEdit"
            .MoveFirst
            .FindFirst ("[UPC] =" & frmSubUPC!UPC)
            If .NoMatch Then
               MsgBox "Failed to locate edited record."
               Set db = Nothing
               Set rs = Nothing
               Exit Sub
            End If
            .Edit
            !UPC = Trim(txtUpcCode)
            .Update
            frmSubUPC.Enabled = True
         Case Else
            MsgBox "This should not be happening. Document what you just did and Call Support."
            Set db = Nothing
            Set rs = Nothing
            Exit Sub
      End Select
   End With

The user selects a value from cboMaterialCodeLookup which requeries a subform to display all UPC codes for a product.

Yes, I know there is only one UPC per product, but they may have other unique options to look up their products.

Anyway they select a record in the subform which updates two txtBoxes (txtMaterialCode & txtUpcCode). They user can then click on cmdEdit which allows them to Change the UPC Code.

When they click on the SAVE button it is suppose to find the original numeric value in tblproduct and update it. However, the .findfirst never returns a match.

Your thoughts and suggestions are appreciated.

Ascent
 
Well, I decided to convert everything to string and it works fine now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top