• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • 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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
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

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

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