First of all, we need to know that null and empty string are different in Access, so if this problem is not handled well, it will cause a lot of trouble, especially in mixed queries.
(Recommended tutorial: access database learning)
The solution is as follows:
var SQLStr:string; begin // SQLStr := 'select * from ordertb where 1>0'; if Trim(Edit1.Text)<>'' then SQLStr := SQLStr +' and serialid like :a'; if Trim(Edit2.Text)<>'' then SQLStr := SQLStr +' and pname like :b'; with ADOQuery1 do begin Close; SQL.Clear; SQL.Add(SQLStr); if Trim(Edit1.Text)<>'' then Parameters.ParamByName('a').Value := '%'+Trim(Edit1.Text)+'%'; if Trim(Edit2.Text)<>''then Parameters.ParamByName('b').Value := '%'+Trim(Edit2.Text)+'%'; Open; end; end;
or:
begin with ADOQuery1 do begin Close; SQL.Clear; SQL.Add('select * from ordertb where 1>0'); if Trim(Edit1.Text)<>'' then SQL.Add(' and serialid like ''%'+Trim(Edit1.Text)+'%'''); if Trim(Edit2.Text)<>''then SQL.Add(' and pname like ''%'+Trim(Edit2.Text)+'%'''); Open; end; end;
Summary :
Filter out fields with empty conditions from the query statement.
The above is the detailed content of access delete empty field records. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

Zend Studio 13.0.1
Powerful PHP integrated development environment