Run-time error 3075

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

I am getting the following error when I run this code and the has a letter in
the value. Does anyone have a suggestion as to why?

Run-time error '3075';

Syntax error (missing operator) in query epression
'ItemParent=9804-025 V1'.

----------------------Code-----------------------------
Private Sub LookUpBomItem_AfterUpdate()
Dim SID As String
Dim rsc As DAO.Recordset
Dim db As Database
Set rsc = Me.RecordsetClone
Set db = CurrentDb

SID = "ItemParent=" & Me.LookUpBomItem.Value


'Record not found add record
DoCmd.GoToRecord , , acNewRec
Me.ItemParent = Me.LookUpBomItem.Column(0)
Me.DESCRIPTION = Me.LookUpBomItem.Column(1)
Me.Beg_Date = Me.LookUpBomItem.Column(2)
Me.End_Date = Me.LookUpBomItem.Column(3)
Me.Version = Me.LookUpBomItem.Column(4)
Me.ImagePath = Me.LookUpBomItem.Column(5)
Me.ItemCompID = Me.LookUpBomItem.Column(6)


ElseIf DCount("ItemParent", "tblItemParent", SID) >= 1 Then

'Go to record of original Number
rsc.FindFirst SID
Me.Bookmark = rsc.Bookmark

End If

Set rsc = Nothing


End Sub
 
D

Daryl S

Mattc66 -

The third parameter of the DCount function needs to be a criteria
expression. If you have a field in the tblItemParent called SID, then the
code would be like this (assuming SID is numeric):

If DCount("ItemParent", "tblItemParent", "[SID] = " & SID) = 0 Then

Or if SID is text:
If DCount("ItemParent", "tblItemParent", "[SID] = '" & SID & "'") = 0 Then

Remember to update both your DCount statements...

--
Daryl S


mattc66 via AccessMonster.com said:
I am getting the following error when I run this code and the has a letter in
the value. Does anyone have a suggestion as to why?

Run-time error '3075';

Syntax error (missing operator) in query epression
'ItemParent=9804-025 V1'.

----------------------Code-----------------------------
Private Sub LookUpBomItem_AfterUpdate()
Dim SID As String
Dim rsc As DAO.Recordset
Dim db As Database
Set rsc = Me.RecordsetClone
Set db = CurrentDb

SID = "ItemParent=" & Me.LookUpBomItem.Value


'Record not found add record
DoCmd.GoToRecord , , acNewRec
Me.ItemParent = Me.LookUpBomItem.Column(0)
Me.DESCRIPTION = Me.LookUpBomItem.Column(1)
Me.Beg_Date = Me.LookUpBomItem.Column(2)
Me.End_Date = Me.LookUpBomItem.Column(3)
Me.Version = Me.LookUpBomItem.Column(4)
Me.ImagePath = Me.LookUpBomItem.Column(5)
Me.ItemCompID = Me.LookUpBomItem.Column(6)


ElseIf DCount("ItemParent", "tblItemParent", SID) >= 1 Then

'Go to record of original Number
rsc.FindFirst SID
Me.Bookmark = rsc.Bookmark

End If

Set rsc = Nothing


End Sub

--
Matt Campbell
mattc (at) saunatec [dot] com




.
 
J

J_Goddard via AccessMonster.com

Hi -

LookUpBomItem.Value appears to be a text string, not numeric. You didn't say
where LookUpBomItem gets its data from, but if it's a bound control, I
suggest you look at the table or query where it is getting its data from.
Your code does not appear to be changing it.

John
 
J

John W. Vinson

I am getting the following error when I run this code and the has a letter in
the value. Does anyone have a suggestion as to why?

Run-time error '3075';

Syntax error (missing operator) in query epression
'ItemParent=9804-025 V1'.

----------------------Code-----------------------------
Private Sub LookUpBomItem_AfterUpdate()
Dim SID As String
Dim rsc As DAO.Recordset
Dim db As Database
Set rsc = Me.RecordsetClone
Set db = CurrentDb

SID = "ItemParent=" & Me.LookUpBomItem.Value

Since SID is a Text field you need the syntactically required quotemarks:

SID = "ItemParent='" & Me.LookUpBomItem.Value & "'"

For readability (don't do it this way!) that's

SID = "ItemParent=' " & Me.LookUpBomItem.Value & " ' "

so the criterion ends up being

ItemParent='9804-025 V1'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top