Thursday 22 February 2007

Tab Control error

Faced with the error:
Run-time error '2101':

The setting you entered isn't valid for this property

on a tab-control - check that you aren't trying to set the current page to a page that isn't visible!

Unhelpful Error Message - "Multiple-step OLE DB operation"

Access 2000 has a maddening habit of giving error messages which can send you in the wrong direction.

If anyone else hits the following:

Run-time error '-2147217887 (80040e21)':

Multiple-step OLE DB operation generated error. Check each OLEDB status value, if available, No work was done.

... then you might want to see if your problem is anything like mine was. My problem turned out that I was trying to save too big a value (999 in fact) into a Byte field; changing it to Integer solved it in an instant.

Thursday 15 February 2007

Hyperlinked Text Boxes on Continuous Forms

Access 2000 has a big restriction with Continuous Forms - whilst data can (obviously!) vary from row to row, most design elements (including button captions) are set once for the form, and cannot be varied from row to row.

A useful workaround is to replace buttons with Text Boxes - specify a text underline, and turn the "Is Hyperlink" property to Yes. Then use a custom function to decide what the text will be - and call that function within a query that provides the recordsource for the form.

That way, record 1 can have a link that says "Renew this expired reservation" whilst record 2 has a link in the same relative position that says "Reinstate this cancelled reservation" or whatever you like. If no option is applicable, then return a zero-length string.

A control can only have a single OnClick event, but you can easily write code that will branch the action according to the other fields in the record, or even based upon the text that you have created for the "hyperlinked" text box - and do nothing if the text box contains a zero-length string.

You COULD achieve nearly the same by having the hyperlinked Text Box use a custom function as its Control Source - but in that case, the cursor will not turn into a Hand/Finger when the mouse is over the Text Box (and that may confuse your users). You only get the hand/finger cursor if the function is within the query, and the control is then based on the resultant field within the query output.