Dmax type mismatch error

Greyowlsl

Mlak Mlak
Local time
Today, 20:19
Joined
Oct 4, 2006
Messages
204
Hi,

What is wrong with this code?

Code:
Private Sub Text91_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim work As String
work = DMax("[document number]", "Drawings", "[Category] = 'Mechanical*'" And "[product] = 'ls*'")
End Sub

- Drawings is a table
- Document number, category and product are columns in the table
- Mechanical and Ls are record fields in the table

thanks,

Leon
 
Last edited:
Did you mean:
Code:
work = DMax("[document number]", "Drawings", [COLOR="Red"]"[Category] = 'Mechanical*' And [product] = 'ls*'"[/COLOR])
End Sub
...or were you trying to use wildcards...
Code:
work = DMax("[document number]", "Drawings", [COLOR="Red"]"[Category] Like 'Mechanical*' And [product] Like 'ls*'"[/COLOR])
End Sub
 
Yea i was trying to use wild cards, i put the new code in but now its doesn't do anything at all when i move my mouse over it.
 
Do one test at a time until you get it working.
Code:
work = DMax("[document number]", "Drawings", "[Category] Like 'Mechanical*'")
Code:
work = DMax("[document number]", "Drawings", "[product] Like 'ls*'")
Code:
work = DMax("[document number]", "Drawings", "[Category] Like 'Mechanical*' And [product] Like 'ls*'")
 
Ive test the code and now i have tried another which also does not work:

Runtime error '62436': Syntax error in date in query expression '[text7] = #20099 #'.

The "20099" is the correct max value that i want displayed in the textbox (text103)
Code:
Private Sub Command107_Click()
Dim work As String
    work = DMax("[Text103]", "Drawings", "[text7] = #" _
        & Forms!frmDmechanical!Text7 & "#")
End Sub
 
in your last expression, surely text103 and text7 are not right for field names in your table.

if you want variables inserting then you have to use for both text103 and the first text7

"[" & text103 &"]" etc, to wrap the variable into the correct expression.

create the condition part as a separate textstring and display it first, to see if it looks right

eg
wherestrg = "[text7] = #" & Forms!frmDmechanical!Text7 & "#"
msgbox(wherestrg)

then use wherestrg as your condition.
 
+1 rep 4 u

Hey thanks i got it working thanks to you, the code looks like this:

Code:
Private Sub Command107_Click()
Dim work As String
wherestrg = " " & Forms!frmDmechanical!Text7 & " "
Me.Text103 = wherestrg
End Sub
 

Users who are viewing this thread

Back
Top Bottom