Error opening subform

N

Noel

MS ACCESS ERROR ON OPENING A SUBFORM

1. For some records, when I click on a button to open a subform, I get an
error. It appears to happen when 1 of 3 different fields for that record is
null. These text fields in particular (First, First2, AAB Case No).

We get this error message: “Visual Basic can’t convert the data type of one
of the arguments you entered.†And further states: “You tried to run a Visual
Basic procedure that executes a method or sets a property of an objectâ€.
After clicking OK, we get an “Action Failed†dialog box showing the macro
name, condition, action name and arguments, and an error message number of
2950.

Macro Name: OpenCaseForm
Condition: True
Action: SetValue
Arguments: [Forms]![Cases]![First2].[Caption], [Forms]![Main]![First2]

2. Also of note: we recently upconverted from Access 97 – although the
problem was still present prior to the upconversion. When we open the
database we get this error message: “Your Microsoft Access database or
project contains a missing or broken reference to the file ‘dao2535.tlb’
version 3.5â€. After clicking through several of these error messages the
database opens normally. We are currently running Access 2007.

Can anyone help me with these two issues?
 
S

Suenaga

Noel said:
MS ACCESS ERROR ON OPENING A SUBFORM

1. For some records, when I click on a button to open a subform, I get an
error. It appears to happen when 1 of 3 different fields for that record
is
null. These text fields in particular (First, First2, AAB Case No).

We get this error message: “Visual Basic can’t convert the data type of
one
of the arguments you entered.†And further states: “You tried to run a
Visual
Basic procedure that executes a method or sets a property of an objectâ€.
After clicking OK, we get an “Action Failed†dialog box showing the
macro
name, condition, action name and arguments, and an error message number of
2950.

Macro Name: OpenCaseForm
Condition: True
Action: SetValue
Arguments: [Forms]![Cases]![First2].[Caption], [Forms]![Main]![First2]

2. Also of note: we recently upconverted from Access 97 – although the
problem was still present prior to the upconversion. When we open the
database we get this error message: “Your Microsoft Access database or
project contains a missing or broken reference to the file ‘dao2535.tlb’
version 3.5â€. After clicking through several of these error messages the
database opens normally. We are currently running Access 2007.

Can anyone help me with these two issues?
 
D

Dirk Goldgar

Noel said:
MS ACCESS ERROR ON OPENING A SUBFORM

1. For some records, when I click on a button to open a subform, I get an
error. It appears to happen when 1 of 3 different fields for that record
is
null. These text fields in particular (First, First2, AAB Case No).

We get this error message: “Visual Basic can’t convert the data type of
one
of the arguments you entered.†And further states: “You tried to run a
Visual
Basic procedure that executes a method or sets a property of an objectâ€.
After clicking OK, we get an “Action Failed†dialog box showing the macro
name, condition, action name and arguments, and an error message number of
2950.

Macro Name: OpenCaseForm
Condition: True
Action: SetValue
Arguments: [Forms]![Cases]![First2].[Caption], [Forms]![Main]![First2]

2. Also of note: we recently upconverted from Access 97 – although the
problem was still present prior to the upconversion. When we open the
database we get this error message: “Your Microsoft Access database or
project contains a missing or broken reference to the file ‘dao2535.tlb’
version 3.5â€. After clicking through several of these error messages the
database opens normally. We are currently running Access 2007.

Can anyone help me with these two issues?


1. You can't set the Caption property of a control to Null, so you had
better change the second argument of your macro to something like this:

[Forms]![Main]![First2] & ""

That should eliminate the error, but I'm not sure what your intentions are,
and it may be that it makes no sense to change the Caption of
[Forms]![Cases]![First2] to an empty string.

By the way, from the sound of it you aren't opening a subform; you're just
opening a second, related form.

2. You don't need that reference and shouldn't be using it. Go into the VB
Editor environment, click Tools -> References..., locate the reference to
DAO 2.5/3.5 Compatibility Library (I think it's called), and uncheck it. I
expect the reference will be marked as MISSING, so you can use that to
locate it if I have the name wrong.
 
T

Tom Wickerath

Hi Noel,
1. For some records, when I click on a button to open a subform, I get an
error. It appears to happen when 1 of 3 different fields for that record is
null. These text fields in particular (First, First2, AAB Case No).

The word "First" is considered a JET Reserved word. I don't know if this is
causing any issues, but I recommend that you always steer clear of using any
reserved words for things that you assign a name to in Access. Here is an
extensive listing of reserved words, compiled by Access MVP Allen Browne:

http://allenbrowne.com/AppIssueBadWord.html

For the macro question, I think you need to remove the .[Caption] part. I do
not use macros myself (other than Autoexec and occasionally Autokeys), but in
looking at the Access 2003 Help file for the SetValue method, the first
argument, Item, needs to refer to a field (not to the caption property of a
control). The following is copied directly from the Help file:

Item
The name of the field, control, or property whose value you want to set.
Enter the field, control, or property name in the Item box in the Action
Arguments section of the Macro window. You must use the full syntax to refer
to this item, such as controlname (for a control on the form or report from
which the macro was called) or Forms!formname!controlname. This is a required
argument.

So, try this instead:
Arguments: [Forms]![Cases]![First2], [Forms]![Main]![First2]

The ‘dao2535.tlb’ library is the "Microsoft DAO 2.5/3.51 Compatibility
Library". You should deselect this reference. This reference was added
automatically when
older databases were first opened in Access 7 (Access 95) and Access 97.

You will likely need to add a reference to the "Microsoft DAO 3.6 Object
Library". If the code compiles without any errors, then you should be good
to go. If any VBA code that is present is so old that it actually requires
the compatibility library to compile, then it should be updated to current
coding practices. The first KB article shown below talks about this more:

http://support.microsoft.com/?id=313233

http://support.microsoft.com/kb/824259

These two articles talk more about the issue of MISSING references in
Access. Both are excellent articles:

Solving Problems with Library References (Allen Browne)
http://allenbrowne.com/ser-38.html

Access Reference Problems (Doug Steele)
http://www.accessmvp.com/djsteele/AccessReferenceErrors.html


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

Noel said:
MS ACCESS ERROR ON OPENING A SUBFORM

1. For some records, when I click on a button to open a subform, I get an
error. It appears to happen when 1 of 3 different fields for that record is
null. These text fields in particular (First, First2, AAB Case No).

We get this error message: “Visual Basic can’t convert the data type of one
of the arguments you entered.†And further states: “You tried to run a Visual
Basic procedure that executes a method or sets a property of an objectâ€.
After clicking OK, we get an “Action Failed†dialog box showing the macro
name, condition, action name and arguments, and an error message number of
2950.

Macro Name: OpenCaseForm
Condition: True
Action: SetValue
Arguments: [Forms]![Cases]![First2].[Caption], [Forms]![Main]![First2]

2. Also of note: we recently upconverted from Access 97 – although the
problem was still present prior to the upconversion. When we open the
database we get this error message: “Your Microsoft Access database or
project contains a missing or broken reference to the file ‘dao2535.tlb’
version 3.5â€. After clicking through several of these error messages the
database opens normally. We are currently running Access 2007.

Can anyone help me with these two issues?
 

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