Wrong Data Type

  • Thread starter michael.p.ryan1
  • Start date
M

michael.p.ryan1

I have a modal pop-up to search for records. There are 3 text boxes each with
it's own string function to return the value of the text box.

'Returns value of text boxes
SearchMake
SearchModel
SearchSerNo

'closes search form
DoCmd.Close

'opens [Form_View Asset]
If IsLoaded("[Form_View asset]") = True Then
[Form_View Asset].Requery
[Form_View Asset].SetFocus
Else
DoCmd.OpenForm [Form_View Asset]
End If

Form_View Asset is based on a query that has the string functions as
criteria. When I try to run the code, i end up with an error message saying

"an expression you entered is the wrong data type for one of the arguments"

Can anyone help me fix this issue?
 
M

michael.p.ryan1

the problem occurs after the IsLoaded event during the "DoCmd.OpenForm
[Form_View Asset]" statement

tried using the quotation marks, worked for the isloaded event but not the
docmd.openform

is there another way to filter a form by certain search criteria beside a
query?

JimBurke via AccessMonster.com said:
I've never used plain old IsLoaded to determine if a form is open - I always
use the format

If CurrentProject.AllForms("frmName").IsLoaded Then

but I would think that you should just supply the name of the form as a
string value, e.g.

If IsLoaded("Form_View asset") = True

Access is likely looking for a form that is exactly what you have specified,
including the brackets. The same goes for your OpenForm statement - it should
be

DoCmd.OpenForm "Form_View Asset"

this is different than when you try to reference a form control name - then,
in your case, you need the brackets, since your form name appears to have a
space in it.


michael.p.ryan1 said:
I have a modal pop-up to search for records. There are 3 text boxes each with
it's own string function to return the value of the text box.

'Returns value of text boxes
SearchMake
SearchModel
SearchSerNo

'closes search form
DoCmd.Close

'opens [Form_View Asset]
If IsLoaded("[Form_View asset]") = True Then
[Form_View Asset].Requery
[Form_View Asset].SetFocus
Else
DoCmd.OpenForm [Form_View Asset]
End If

Form_View Asset is based on a query that has the string functions as
criteria. When I try to run the code, i end up with an error message saying

"an expression you entered is the wrong data type for one of the arguments"

Can anyone help me fix this issue?
 
M

michael.p.ryan1

When i try yo use the format DoCmd.OpenFrom "Form_View Asset", it didn't
work. however DoCmd.OpenForm "View Asset" does and it fixes everything

JimBurke via AccessMonster.com said:
Did you use the format DoCmd.OpenFrom "Form_View Asset", removing the
brackets? This should work if that is the name of the form, What error are
you getting? Is the Open itself failing or does it fail in the form's open
event? If you have an error in a form's open event the OpenForm will fail.
There may be other events that can cause the OpenForm to fail as well - On
Current, On Activate, etc. I would put a breakpoint in the form's Open event
at the very beginning and see what happens, if you used that format of
OpenForm and that is the correct form name.

michael.p.ryan1 said:
the problem occurs after the IsLoaded event during the "DoCmd.OpenForm
[Form_View Asset]" statement

tried using the quotation marks, worked for the isloaded event but not the
docmd.openform

is there another way to filter a form by certain search criteria beside a
query?
I've never used plain old IsLoaded to determine if a form is open - I always
use the format
[quoted text clipped - 41 lines]
Can anyone help me fix this issue?
 

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