Please Help!!!!

  • Thread starter Thread starter callykid65
  • Start date Start date
C

callykid65

Guest
I'm trying to update a table based on a field in an unbound form

Here’s the code:
Private Sub Command38_Click()
Dim strPartNo As String
strPartNo = Me!fldPartNumber
Set dbs = CurrentDb()
Set rstBalUD = dbs.OpenRecordset("SELECT * from PartsInventory WHERE CO_PART_NO = [fldPartNumber]", 1)
rsBalud!SERVBAL = Me!fldNewServBal
rstBalUD.UPDATE

End Sub



Here’s the error:
Run-time error ‘3011’
The Mircosoft jet database engine could not find the object ‘SELECT *
from Partsinventory WHERE CO_PART_NO = [fldPartNumber]’.
Make sure the object exists and that you spell its name and path name
correctly.
 
Try something like this

Dim strStoreSQL As String
strStoreSQL = ("SELECT * from PartsInventory WHERE PartsInventory.CO_PART_NO = " & [fldPartNumber].Value

Set daoRst = daoDbs.OpenRecordset(strStoreSQL)
 
You already have a variable strPartNo which holds this value. Use

CDbl(strPartNo) instead of the [fldPartNumber] which it won't recognise as a value.
 

Users who are viewing this thread

Back
Top Bottom