• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

How check whether a form is bound to a recordset?

I have a form that I open, then bind a recordset to.

The form's On Current event fires when the form is first opened, before the recordset is bound, and trips an error, since the controls it examines are not yet populated.

How can I write a check to see whether there is a recordset present, to filter out these commands from On Current?

[NB it's possible that the error is due to something else, since only one of several lines in On Current triggers the error:
Me.SectionFinder.Value = Me.Controls("Type").Value
gives error 438: object doesn't support this property or method.]

Happy with an answer to either!

jc
0
johnclarke123
Asked:
johnclarke123
  • 3
  • 2
1 Solution
 
johnclarke123Author Commented:
Sorry - make that runtime error 2424 'The expression has a field, control or property name that Microsoft Access can't find'
0
 
peter57rCommented:
Hi johnclarke123,

I don't believe you can avoid the errors using this approach.  The fields will show #Error until a valid recordsource is provided.
Why can't you set the form to a valid source and then change it to what you want.
Pete
0
 
rockiroadsCommented:
Why cant u check if a recordsource is present?

If Me.RecordSource <> "" then Me.SectionFinder.Value = Me.Controls("Type").Value

Is that what u mean?

or the other way is to handle errors

on error resume next

err.clear
Me.SectionFinder.Value = Me.Controls("Type").Value

if err.number >0 and err.number <> 436 then  msgbox err.description


0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
rockiroadsCommented:
urm, try 438 instead of 436

0
 
johnclarke123Author Commented:
That would do it.
Thanks a lot.
jc
0
 
rockiroadsCommented:
Its tweaks galore day today :)

Thats exactly what Ive had to do with cross site scripting Im doing right now. Not exactly a generic solution but it works
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now