P
P
Pavel2014-09-09 14:54:09
MySQL
Pavel, 2014-09-09 14:54:09

How to put a filter in a simple client form of Access DBMS in VBA?

There is a MySQL database .
As a "skin" there is remote work with MySQL tables using the Microsoft Access DBMS . The access is carried out using the odbc driver.

For convenient work on top of the table, an Access form was created using the standard procedure in Access: "Client Forms --> Form" . Wrote several useful baubles on VBA . Everything seems to be working, but at the testing stage the following problem arose:
the standard filter below searches for all the fields of the table. For this reason, the search is incredibly long.

Questions:
1) How to write your own filter in the client form ?
2) Можно ли как-нибудь настроить фильтр по умолчанию на фильтр только по одному полю таблицы?

Искренне прошу прощения, если мой вопрос кому-то покажется глупым. На VBA работаю неделю.

Посоветуйте решения данной задачи.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Павел, 2014-09-16
@PavelMSTU

Сам спросил, сам и отвечаю.

Private Sub ExampleObjct_Click()
    Dim strSql As String
    strSql = "SELECT * FROM some_table WHERE some_field='some_value' order by ID ASC;"
    Me.RecordSource = strSql
End Sub

Note : If error 3464 ("Data Type Mismatch") occurs, then you should probably change ints to strings even where you do not expect this.
I had ID schnicks. For example this worked :
And this didn't work :
The reason is the lack of quotes in the ID values.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question