1

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?

Fionnuala
  • 90,370
  • 7
  • 114
  • 152
kkbondo
  • 11
  • 1
  • You'll get quicker answers if you tell us which line produces the error. Indeed, if you looked at the line producing the error, you might very well be able to figure out the answer yourself, without posting a question on SO. – David-W-Fenton May 17 '10 at 21:53

3 Answers3

1

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

Fionnuala
  • 90,370
  • 7
  • 114
  • 152
0

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
  • 15,313
  • 25
  • 73
  • 114
  • 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. – Fionnuala May 17 '10 at 10:34
  • @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 May 17 '10 at 10:37
0

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

Community
  • 1
  • 1
Philippe Grondier
  • 10,900
  • 3
  • 33
  • 72