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

How should I use recordset with conditionals?

I'm trying to show combinations of my data on a query called Sales by using a form and 3 combo boxes. But when there are no combinations I want the form to show a message saying no combinations found.

I was told I should look up what RECORDSET is otherwise I wouldn't get it. So I didn't but I'm still not getting anywhere. I'm new to this but willing to learn.
Combo boxes:
companycell, companyflux, companyribbon
fields on the query and table that i'm looking up are:
[company name] (from table: flux information and query: sales) and [ribbon company] (from table: ribbon information and query: sales both hold text

Here is my code:


Expand|Select|Wrap|Line Numbers
  1. Private Sub Findbtm_Click()
  2.  
  3. Dim rs1 As DAO.Recordset
  4. Dim rs2 As DAO.Recordset
  5.  
  6. 'Attach recordsets to queries
  7. Set rs1 = CurrentDb.OpenRecordset("SELECT * FROM [Flux Information] WHERE [Company Name]" & "='" & [Companyflux] & "'", dbOpenSnapshot)
  8. Set rs2 = CurrentDb.OpenRecordset("SELECT * FROM [Ribbon Information] WHERE [Ribbon Company]" & "='" & [CompanyRibbon] & "'", dbOpenSnapshot)
  9.  
  10. 'companycell is required
  11. If Me.CompanyCell.Value = "" Then
  12. Beep
  13.     Select Case MsgBox("all fields are required", vbOK)
  14.     Case vbOK: 'do nothing
  15.     Case Else: 'do nothing
  16.     End Select
  17. Else
  18. Me.cellbox = Me.CompanyCell
  19.  
  20. 'Evaluate values. if either of the combo boxes are empty then it will look up every possible combination and show it on the query 'Sales'
  21.     If [Companyflux] = "" Or [CompanyRibbon] = "" Then
  22.         MsgBox ("empty fields")
  23.         DoCmd.OpenQuery "sales"
  24.         DoCmd.OpenReport "sales", acViewReport
  25.  'if they aren't empty then it is going to se if the boxes match a record and open the query 'Sales'
  26.     ElseIf Not rs1.EOF And Not rs2.EOF Then
  27.     MsgBox ("finding records")
  28.     DoCmd.OpenQuery "sales"
  29.     DoCmd.OpenReport "sales", acViewReport
  30.  'If there is no data matching combination, say no match
  31.     Else
  32.     MsgBox ("no match")
  33.    End If
  34. End If
  35. End Sub
This is pretty much working, except the case were there are no combinations and it is still showing me the query/report 'Sales' instead of a message saying no match.

Any help or references would be much appreciated.
Thank you
Jun 22 '10 #1
0 807

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

Similar topics

1
by: FHuang | last post by:
Ok, I'm having some trouble with conditionals, for some reason PHP is screwing them up. First off, here is the code: <?php $username = "fred"; $userdata = "./$username.txt"; $fp =...
15
by: Joshua Ginsberg | last post by:
Is there any plan to include inline conditionals in Python? For example: def isNegative(x): return x < 0 ? True : False Thanks! -jag --
1
by: Paul Dale | last post by:
Hi All, I know that several of you will probably want to reply "you should write a parser", and I may. For that matter any tips on theory in that direction would be appreciated. However, if...
3
by: steven | last post by:
Is it possible to combine conditionals to call out data? I have a list of records that include a date. I can call out all dates after the date after tomorrow: IIf(Date()+1)<,...,... And I can...
3
by: carrionk | last post by:
Hi, I'm running an ADO Recorset from Excel to gather data from Access. Basically it's copying the records of a query -that runs without problem in Access- That query has an expression with NZ()...
4
by: Leon Lambert | last post by:
I would appreciate it if someone could help me understand NaN handling with respect to conditionals in IL code. I am playing with a small IL interpreter and having a little problem with it....
11
by: .Net Sports | last post by:
I need to convert some C# ?Conditionals over to vb.net (most likely in vb.net using If..Then statements), but the C#2VBNETconverter by KamalPatel isn't converting them: string PurchaseType =...
6
by: chopin | last post by:
I am working in Access 2003 in Windows XP. I am using Visual Basic for Applications, using DAO to write my modules. What I need to do is write a module that will compare each row to see if they are...
5
by: Hul Tytus | last post by:
comp.lang.c c programs & shell conditionals How is a unix shell script made to respond to the value returned by a program compiled from c code? The shell script below is my current effort,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.