473,387 Members | 1,420 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,387 software developers and data experts.

Make selection from two list boxes

48
Hello, I have two list boxes; the first one has First Names and the second list box has Last Names. I want the user to be able to select the first and last name from each text box and a Report will be generated. I wrote the code below, but it does not work. Can someone halp me to figure this out. I need it badly.
THank you in advance.

[code=vb]
Private Sub cmdName_Click()
Dim pstCriteria As String

If IsFirst([LstLastName]) And IsLast([LstFirstName]) Then
pstrCriteria = "[LastName] >= # " & [FirstName] & "# and [FirstName]<=#" & [LastName] & "#"

DoCmd.OpenReport "rptName", acViewPreview, , pstrCriteria


End If
[/End]
Nov 6 '07 #1
3 1394
ADezii
8,834 Expert 8TB
Hello, I have two list boxes; the first one has First Names and the second list box has Last Names. I want the user to be able to select the first and last name from each text box and a Report will be generated. I wrote the code below, but it does not work. Can someone halp me to figure this out. I need it badly.
THank you in advance.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdName_Click()
  3. Dim pstCriteria As String
  4.  
  5. If IsFirst([LstLastName]) And IsLast([LstFirstName]) Then
  6.               pstrCriteria = "[LastName] >= # " & [FirstName] & "# and [FirstName]<=#" & [LastName] & "#"
  7.  
  8. DoCmd.OpenReport "rptName", acViewPreview, , pstrCriteria
  9.  
  10.  
  11.   End If
  12.  
'This is the correct syntax, I have no idea of what you are trying to accomplish in the If...End If Clause:
Expand|Select|Wrap|Line Numbers
  1. Dim strCriteria As String
  2.  
  3. strCriteria = "[FirstName] = '" & Me![LstFirstName] & "' And [LastName] = '" & Me![LstLastName] & "'"
  4. DoCmd.OpenReport "rptName", acViewPreview, , strCriteria
  5.  
Nov 7 '07 #2
margot
48
'This is the correct syntax, I have no idea of what you are trying to accomplish in the If...End If Clause:
Expand|Select|Wrap|Line Numbers
  1. Dim strCriteria As String
  2.  
  3. strCriteria = "[FirstName] = '" & Me![LstFirstName] & "' And [LastName] = '" & Me![LstLastName] & "'"
  4. DoCmd.OpenReport "rptName", acViewPreview, , strCriteria
  5.  
Thank you sir. It works great.
Best.
Nov 7 '07 #3
ADezii
8,834 Expert 8TB
Thank you sir. It works great.
Best.
Happy that it worked out for you.
Nov 7 '07 #4

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

Similar topics

2
by: Jeff | last post by:
Hello All: What I am trying to do is bind a textbox (really several text boxes) based on a list box selection. Basically what I'm dealing with are two tables with a 1 to 1 relationship. I...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
2
by: Jeff | last post by:
Hello All: What I am trying to do is bind a textbox (really several text boxes) based on a list box selection. Basically what I'm dealing with are two tables with a 1 to 1 relationship. I...
3
by: ZaphodBBB | last post by:
Hi (Windows XP Pro, MS Access 2003) I have a form that has quite a number of list boxes on it. The list boxes only have 3 or 4 selections possible...Pass, Fail, Average, Not...
2
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.