table filter

S

smason

i am trying to write some code that will open a table and filter it (in this
case all apps where the date in is >=01/01/2008

like this
Public Sub filter()
DoCmd.OpenTable ("[applicant tbl]"), acViewNormal, , "[datein]=>#01/01/2008#"

End Sub

where am i going wrong! i know i can do thisin a query but iam teaching
myself VBA pleae help
 
A

Allen Browne

Tables are just for storing the data. They are not the interface.

Create a form (in datasheet view if you want it to look like a table.)

Then open it like this:
DoCmd.OpenForm "Form1", WhereCondition:="[datein]=>#01/01/2008#"
 
S

smason

excellent thanks for that

Allen Browne said:
Tables are just for storing the data. They are not the interface.

Create a form (in datasheet view if you want it to look like a table.)

Then open it like this:
DoCmd.OpenForm "Form1", WhereCondition:="[datein]=>#01/01/2008#"

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

smason said:
i am trying to write some code that will open a table and filter it (in
this
case all apps where the date in is >=01/01/2008

like this
Public Sub filter()
DoCmd.OpenTable ("[applicant tbl]"), acViewNormal, ,
"[datein]=>#01/01/2008#"

End Sub

where am i going wrong! i know i can do thisin a query but iam teaching
myself VBA pleae help
 
S

smason

Hello

how would i use a filter like this "DatePart("q", [datein]) = 1"

Allen Browne said:
Tables are just for storing the data. They are not the interface.

Create a form (in datasheet view if you want it to look like a table.)

Then open it like this:
DoCmd.OpenForm "Form1", WhereCondition:="[datein]=>#01/01/2008#"

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

smason said:
i am trying to write some code that will open a table and filter it (in
this
case all apps where the date in is >=01/01/2008

like this
Public Sub filter()
DoCmd.OpenTable ("[applicant tbl]"), acViewNormal, ,
"[datein]=>#01/01/2008#"

End Sub

where am i going wrong! i know i can do thisin a query but iam teaching
myself VBA pleae help
 
A

Allen Browne

That should be okay, except you have to double-up the quotes inside the
quotes:
"DatePart(""q"", [datein]) = 1"

If you find it easier:
"Month([datein]) Between 1 and 3"

More details about quotes inside quotes:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

smason said:
Hello

how would i use a filter like this "DatePart("q", [datein]) = 1"

Allen Browne said:
Tables are just for storing the data. They are not the interface.

Create a form (in datasheet view if you want it to look like a table.)

Then open it like this:
DoCmd.OpenForm "Form1", WhereCondition:="[datein]=>#01/01/2008#"

smason said:
i am trying to write some code that will open a table and filter it (in
this
case all apps where the date in is >=01/01/2008

like this
Public Sub filter()
DoCmd.OpenTable ("[applicant tbl]"), acViewNormal, ,
"[datein]=>#01/01/2008#"

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top