0

I'm facing an issue with Access forms linked to SQL Server tables. I typically set the forms' RecordSource property using VBA in the Form_Load event, like this:

Set Me.Recordset = CurrentDb.OpenRecordset("some SQL")

I'm using linked tables to SQL Server.

Everything works fine until I go into the form's design view and make some changes (e.g., move textboxes). Afterward, the automatically generated RecordSource in the form properties becomes corrupted (incomplete) and produces an error.

For example:

Select field1,field2,field3 from Table where field4="test data"

changes to:

Select field1,field2,field3 from Table where field4="te

Such Record Source naturally produces an error and is very time consuming because that happens every time I change something in form design.

The only option that I am left with is that I manually delete Record Source in properties window and let it populate again automatically on Form_Load again.

1 Answer 1

1

Set the RecordSource directly at the form open event:

Me.RecordSource = "Select field1,field2,field3 from Table where field4='test data'"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.