views:

43

answers:

3

I have a code like this:

Dim strResponses As String
strResponses = Forms!frmResponses.QstnID.OpenArgs
If Len(strResponses) > 0 Then
     Me![QstnID].DefaultValue = Me.OpenArgs
  End If

When I run it, its gives error 438. Can someone help me to know where the error is?

+1  A: 

Surely that should be:

 strResponses = Forms!frmResponses.OpenArgs

Or

 strResponses = Me.OpenArgs

Only forms, and in more recent versions, reports, have an OpenArgs property, hence, I imagine, the error "Object doesn't support this property or method".

Remou
A: 

Is the error 438 happening on the line:

Me![QstnID].DefaultValue = Me.OpenArgs

What happens if, as a test, you try setting Me![QstnID].DefaultValue to something else? e.g.

Me![QstnID].DefaultValue=42

So, is the problem definitely connected to OpenArgs?

hawbsl
@hawbsl I cannot see how Forms!frmResponses.QstnID.OpenArgs can be the correct syntax. QstnID sounds like a control, which will not have a OpenArgs property.
Remou
@Remou, oh yeah, i see. i guess the error's occurring on the line Forms!frmResponses.QstnID.OpenArgs. +1 your answer. but, like i've said, it'd be nice know for sure on which line it errors.
hawbsl
A: 

to know on which line is your error, you can do the following

  1. create an myError labal
  2. add a 'on error goto myError' clause
  3. number your code lines
  4. use the 'erl' value to display errored line number

you can also use the MZ-Tools for VBA add-in, that could do this for you in a few clicks, once correctly parametered. You can also check this more complete answer: ms-access-vba-and-error-handling

Philippe Grondier