473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ApplyFilter....again

10
hi, same problem with applyfilter but i'm close.

what i have done so far is a log in screen that takes a username and password and the user name is stored in a variable called StrUserName.

If Me.txtPassword = DLookup("Password", "QryLoginStudent", "UserName = '" & Me.txtUserName & "'") Then

StrUserName = Me.txtUserName

if the username and password match a main screen appears with a command button called student details and behind that button is this code:

DoCmd.OpenForm "frmStudentDetails"
DoCmd.ApplyFilter , "UserName = " & StrUserName

what happens is that when i click on the button student details a 'Enter Parameter Value' appears where i have to type the students username again to view the details.

i was wondering how to just show the students details WITHOUT the 'Enter Parameter Value' . it will just be there on the form already based on the students username.

Thanks
Feb 26 '07 #1
7 1561
Killer42
8,435 Expert 8TB
I think you may need to specify your filter as a parameter of the OpenForm, rather than using ApplyFilter afterward. That being the case, you probably don't want any parameters in the form's underlying query.

This is just a guess, though.
Feb 26 '07 #2
zamir
10
so what are you trying to say try to have it in one line?
Feb 26 '07 #3
Killer42
8,435 Expert 8TB
so what are you trying to say try to have it in one line?
Um... I think so.

What I'm saying is to look up the syntax of the DoCmd.OpenForm statement. It includes parameters for filter name and Where condition.
Feb 26 '07 #4
zamir
10
I have followed your advice and tried it, here is the following code:

DoCmd.OpenForm "frmViewStudentDetails", acNormal, "UserName", "StrUserName", acFormPropertySettings, acWindowNormal

The Enter Parameter value still appears but before the form is opened and when you type in a username it gets the wrong details.

I feel whats embolden in the code above maybe the problem but i don't know what it is.

Do i have to consider a different approach, does anyone have any suggestions?

Thanks
Feb 27 '07 #5
Killer42
8,435 Expert 8TB
I have followed your advice and tried it, here is the following code:

DoCmd.OpenForm "frmViewStudentDetails", acNormal, "UserName", "StrUserName", acFormPropertySettings, acWindowNormal

The Enter Parameter value still appears but before the form is opened and when you type in a username it gets the wrong details.

I feel whats embolden in the code above maybe the problem but i don't know what it is.

Do i have to consider a different approach, does anyone have any suggestions?
According to online help, the syntax is...
expression.OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)
So you are specifying...
  • FormName = "frmViewStudentDetails"
  • View = acNormal
  • FilterName = "UserName"
  • WhereCondition = "StrUserName"
  • DataMode = acFormPropertySettings
  • WindowMode = acWindowNormal
I'm not too sure about the FilterName (I've always been a bit vague about filters) but I'm pretty sure "StrUserName" is not a valid Where clause. According to the online help again, this should be
A string expression that's a valid SQL WHERE clause without the word WHERE.
So, for this to work I think you need to concatenate your field name (presumably UserName), and equals sign, and the value of StrUserName in single quotes. Try this and see whether it helps...
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmViewStudentDetails", acNormal, , "UserName = '" & StrUserName & "'", acFormPropertySettings, acWindowNormal
For this to work, I think (not certain) that the form (frmViewStudentDetails) needs to be based on a query which returns all the student records. The Where clause is then applied to select just the record(s) you want.

Once again though, I don't have a lot of experience in this area. We may need to try some of the experts in the Access forum. This will be simple stuff for them.
Feb 27 '07 #6
zamir
10
IT WORKS! UNBELIEVABLE

thanks for your help, the code you have given worked.

cheers
Feb 27 '07 #7
Killer42
8,435 Expert 8TB
IT WORKS! UNBELIEVABLE

thanks for your help, the code you have given worked.
Great! Glad I could help.
Feb 27 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michelle Dennard | last post by:
I am attempting to use the ApplyFilter command on a form in access and I am having some questions. Basically I have a form inwhich I select three things that constitute a key for each item. 1)...
2
by: webvigator2k | last post by:
I have a database that I've converted from 8 seperate tables into one cumulative table. instead of having 8 unique tables, there are 8 different tags now (machine1, machine2 etc) that ID every...
4
by: Bob Darlington | last post by:
Can anyone tell me why: DoCmd.ApplyFilter, "ElectID = " & vNewElectID should work in an mdb, but fail when the file is converted to an mde. It fails with a 'Enter Parameter Value: ElectID"...
4
by: Colin Spalding | last post by:
How can I use the ApplyFilter method when both the control source to be filtered, and the filter are variables. I have tried the following syntax: DoCmd.ApplyFilter , "strSubject ='" & strGroup...
3
by: Robert_5032 | last post by:
I cant get my filter to work with variables Its working fine if I "hardcode" the issueType I want to filter on. Works fine: DoCmd.ApplyFilter , "issueType = 1" Works NOT: DoCmd.ApplyFilter ,...
2
by: John Smith | last post by:
The following code will not work for filtering records on a form: DoCmd.ApplyFilter , "Award =" & Not Null I use the following line to filter for a series of Yes/No boxes without trouble: ...
1
by: Jimmy Stewart | last post by:
I have a continuous form with a list of items from a table. One of the fields in the table is "print". this allows the user to select items from the list on the form for printing in a report. on...
1
by: zamir | last post by:
hi, can you applyfilter to a form based on what a user will enter in a login screen and have a specific record show up on that form. the code i already have is this: DoCmd.ApplyFilter ,...
2
by: dkohel | last post by:
What is wrong with the following code? I am trying to filter a form based on the selection of a combobox named cblPRD Dim currentFilter currentFilter = " = '" & Me!cboPRD & "'" Filter =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.