Error 13 Frustration!

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
 
D

Dirk Goldgar

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 ...
 
D

DubboPete

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]) & '*'"
:)
 
D

Dirk Goldgar

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".
 
D

DubboPete

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....
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 

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