Error 13 Frustration!

  • Thread starter Thread starter DubboPete
  • Start date Start date
D

DubboPete

Hi all,

I have a problem with some code. It keeps spitting back type
mismatch. I have a similar thing to this in another database and it
works fine when fired by an option group-click. Here's the code:

Private Sub Text27_AfterUpdate()

If Me.Frame15 = 1 Then
Me.FrmAssetSubform.Form.RecordSource = "SELECT assets2.[ASSET
NUMBER]," & _
"assets2.[ASSET NAME], assets2.[ASSET TYPE], assets2.DEPARTMENT,
assets2.USER," & _
"assets2.[DATE ACQUIRED] FROM assets2 WHERE (((assets2.[ASSET
NUMBER]) Like" & _
"([Forms]![FrmAssetQuery]![text27]) & " * "))"
ElseIf Me.Frame15 = 2 Then

and so on...

Can't get past the first if me...then...statement. Any clues anyone?

cheers
DubboPete
 
DubboPete said:
Hi all,

I have a problem with some code. It keeps spitting back type
mismatch. I have a similar thing to this in another database and it
works fine when fired by an option group-click. Here's the code:

Private Sub Text27_AfterUpdate()

If Me.Frame15 = 1 Then
Me.FrmAssetSubform.Form.RecordSource = "SELECT assets2.[ASSET
NUMBER]," & _
"assets2.[ASSET NAME], assets2.[ASSET TYPE], assets2.DEPARTMENT,
assets2.USER," & _
"assets2.[DATE ACQUIRED] FROM assets2 WHERE (((assets2.[ASSET
NUMBER]) Like" & _
"([Forms]![FrmAssetQuery]![text27]) & " * "))"
ElseIf Me.Frame15 = 2 Then

and so on...

Can't get past the first if me...then...statement. Any clues anyone?



It looks to me like you've got some bad quoting at the end of the SQL string
you're building. Try this:

If Me.Frame15 = 1 Then
Me.FrmAssetSubform.Form.RecordSource = _
"SELECT [ASSET NUMBER], [ASSET NAME], [ASSET TYPE], " & _
"DEPARTMENT, USER, [DATE ACQUIRED] " & _
"FROM assets2 " & _
"WHERE [ASSET NUMBER] Like " & _
"[Forms]![FrmAssetQuery]![text27]) & '*'"
ElseIf ...
 
I have a problem with some code.  It keeps spitting back type
mismatch.   I have a similar thing to this in another database and it
works fine when fired by an option group-click.   Here's the code:
Private Sub Text27_AfterUpdate()
   If Me.Frame15 = 1 Then
       Me.FrmAssetSubform.Form.RecordSource = "SELECT assets2.[ASSET
NUMBER]," & _
"assets2.[ASSET NAME], assets2.[ASSET TYPE], assets2.DEPARTMENT,
assets2.USER," & _
"assets2.[DATE ACQUIRED] FROM assets2 WHERE (((assets2.[ASSET
NUMBER]) Like" & _
"([Forms]![FrmAssetQuery]![text27]) & " * "))"
   ElseIf Me.Frame15 = 2 Then
               and so on...
Can't get past the first if me...then...statement.  Any clues anyone?

It looks to me like you've got some bad quoting at the end of the SQL string
you're building.  Try this:

    If Me.Frame15 = 1 Then
         Me.FrmAssetSubform.Form.RecordSource = _
            "SELECT [ASSET NUMBER], [ASSET NAME], [ASSET TYPE], " & _
                "DEPARTMENT, USER, [DATE ACQUIRED] " & _
            "FROM assets2 " & _
            "WHERE [ASSET NUMBER] Like " & _
                    "[Forms]![FrmAssetQuery]![text27])& '*'"
    ElseIf ...

--
Dirk Goldgar, MS Access MVPwww.datagnostics.com

(please reply to the newsgroup)- Hide quoted text -

- Show quoted text -

Thanks Dirk, that cleared it up - but not before Access told me
there's an extra ) at the end, as in "[Forms]![FrmAssetQuery]!
[text27]) & '*'"
:-)
 
DubboPete said:
Thanks Dirk, that cleared it up - but not before Access told me
there's an extra ) at the end, as in "[Forms]![FrmAssetQuery]!
[text27]) & '*'"


Sorry about that -- I thought I'd cleaned up all those extra parentheses
that the Access query designer insists on adding "just in case".
 
Thanks Dirk, that cleared it up - but not before Access told me
there's an extra ) at the end, as in "[Forms]![FrmAssetQuery]!
[text27]) & '*'"

Sorry about that -- I thought I'd cleaned up all those extra parentheses
that the Access query designer insists on adding "just in case".

no probs mate, thanks for the help....
 
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
Back
Top