A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Form for query



 
 
Thread Tools Display Modes
  #1  
Old October 19th, 2009, 03:56 AM posted to microsoft.public.access.forms
sebastico
external usenet poster
 
Posts: 74
Default Form for query

Hi Access comm

I have been trying to have a form working as a query in Access 2003. I also
have been studying the Access Help, and revising the Access forums and the
Allen Brown web, etc, no success.

In such form, the idea is when a user filters in the "texTown" textbox
Access must show all the records.
I already have a form in design view. I add five (non linked) textbox and I
give the names from the Table 1ObID:
txtObrID
txtAutNmb
txtYy
txtTitle
txtRes
txtTown

I also added two command buttons, one with the text "Filter "and the other
"Show All".
In the "Show All" button I added in the event click:
DoCmd.ShowAllRecords “I hope this to take off any filter and will show all
records.
DoCmd.ApplyFilter sFilter

In the other button I add this code in the event click:
Dim sFilter as String
if len(Me.txtObrID.value)0 then
sFiltro="ObrID='" & txtObrID.value & "' and " 'TEXT
sFiltro="ObrID='" # txtObrID.value & "' and " 'DATE
sFiltro="ObrID=" & txtObrID.value & "' and " 'NUMBER
end if

if len(Me.txtAutNmb.value)0 then
sFiltro="AutNmb='" & txtAutNmb.value & "' and " 'TEXT
sFiltro=" AutNmb ='" # txtAutNmb.value & "' and " 'DATE
sFiltro=" AutNmb =" & txtAutNmb.value & "' and " 'NUMBER
end if

if len(Me. txtYy.value)0 then
sFiltro="Yy='" & txtYy.value & "' and " 'TEXT
sFiltro=" Yy ='" # txtYy.value & "' and " 'DATE
sFiltro=" Yy =" & txtYy.value & "' and " 'NUMBER
end if

if len(Me. txtTitle.value)0 then
sFiltro="Title='" & txtTitle.value & "' and " 'TEXT
sFiltro=" Title ='" # txtTitle.value & "' and " 'DATE
sFiltro=" Title =" & txtYy.value & "' and " 'NUMBER
end if

if len(Me. txtRes.value)0 then
sFiltro="Res='" & txtRes.value & "' and " 'TEXT
sFiltro=" Res ='" # txtRes.value & "' and " 'DATE
sFiltro=" Res =" & txtRes.value & "' and " 'NUMBER
end if

if len(Me. txtTown.value)0 then
sFiltro="Town='" & txt Town.value & "' and " 'TEXT
sFiltro=" Town ='" # txt Town.value & "' and " 'DATE
sFiltro=" Town =" & txt Town.value & "' and " 'NUMBER
end if

However, when I click the buttons nothing happens. Could you help to fix
what I’m doing wrong? I’m also interested in displaying records in a Report,
is that possible?

Many thanks

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.