I am trying to get a recordset to skip over empty cells in the data...however, I really don't want to use If, Then, Else statements as I already have quite a few in the code, and by using more, it's causing the code not to run
I've been trying to use:
If IsNull(field) = True Then GoTo CertainSpot
here is where I'd like it to continue if it is false, without using If, Then, Else...
so basically, if the above is true, go to that spot...otherwise, just continue running the code
Is there any way of doing this and avoiding the If, Then, Else statements?
I have a SQL that enables the user to search the form from different combo boxes to narrow down the data. I can get this to work but it only finds the fields that exactly match their input data. I want them to be able to type something in the combo box and then it pull up anything with that value in that field, whether it is 1839B or B1839 it should find both if I type in 1839
Here is my sql statements
SELECT DISTINCT [WeldingSpecification].[Spec], [WeldingSpecification].[Steel Type], [WeldingSpecification].[Group11], [WeldingSpecification].[Group143], [WeldingSpecification].[Substitute1] FROM WeldingSpecification WHERE ((([spec] & "") Like IIf([Forms]![frmSearchCriteriaMain]![spec] Is Null,"*", [Forms]![frmSearchCriteriaMain]![Spec] & "*")) And (([SteelType] & "") Like IIf([Forms]![frmSearchCriteriaMain]![SteelType] Is Null,"*",[Forms]![frmSearchCriteriaMain]![SteelType] & "*")) And (([Group11] & "") Like IIf([Forms]![frmSearchCriteriaMain]![Group11] Is Null,"*",[Forms]![frmSearchCriteriaMain]![Group11] & "*")) And (([Group143] & "") Like IIf([Forms]![frmSearchCriteriaMain]![Group143] Is Null,"*",[Forms]![frmSearchCriteriaMain]![Group143] & "*")) And (([Substitute1] & "")([spec] Like "*" & Forms![frmSearchCriteriaMain]!Spec & "*" & "") Like IIf([Forms]![frmSearchCriteriaMain]![Substitute1] Is Null,"*",[Forms]![frmSearchCriteriaMain]![Substitute1] & "*"))
Any help is appreciated, please ask if you do not understand fully
I am using a query with Like statements that looks at a field in a form. The form defaults to "*" so that all of the records will show. You can search with the normal wildcards. The problem I have is that the records containing Null values don't appear. I was trying to see if I could use an IIF statement in the criteria of the query, but have had difficulty. What is the proper way to have all records show if * is the default, but only the specific criteria if something is entered using wildcards?
Within my query I have a field that I need to do a nested IIf Statement that has a NULL value. The name of the field is "smokingcessation". The possible responses are a "1" = Yes, "2"= No, "3"=Unknown and there is also the possibility of a "no answer" at all (blank). I've got the following statement to work so far but need to include the possibility of a blank/no answer response. My statement so far is as follows and is working:
How would I do a statement that would take into account the existing possibilities plus that of a blank (NULL) answer and leave the field blank in that case? In otherwords, I need to see a "Yes", "No", "Unknown" or a blank field.
I've written a query that is assigned either a pass/fail depending on certain criteria. Here is the query:
Pass/Fail: IIf([jc_actlevel]="Yes" And [jc_diet]="Yes" And [jc_medications]="Yes" And [jc_followup]="Yes" And [jc_sympworse]="Yes" And [jc_weightmonitor]="Yes","Passed","Failed")
I want this query to only show me records that have a "yes" or "no" value but some on the records have neither a "yes" OR "no" (just a NULL value)and are showing up in the query as "failed" which is throwing off my count of how many records met the pass/fail criteria (see attached).
How can I NOT show records that have a NULL value in my query? Thanks for any help.
It might be an easy one but I just wasted the past hour deciphering through my code in order to solve the run-time error '94' that I'm getting when trying to execute the following code:
Code: Private Sub cmdUpdateDates_Click() '################################### 'This sub aims at combining the timesheet date and the start and end time into the fields [Start Time] and [End Time]. '################################### Dim intCounter As Integer intCounter = 0 Dim rs As ADODB.Recordset
A bit of a weird one, I've got a query and the criteria for showing records is that one particular field is null. However the query is showing records with the values in the field chosen for the Is Null.
Not sure why this is happening, has anyone come across this problem before?
Can anyone give me any guidance on how to use IFF statements in microsoft access? or Has anyone got a link to a good website that can help me? I need to use the formula below to determine if the quantity of an order from a store is greater than the quantity that is in stock at the warehouse and produce a message message.IIF([quantityordered])(=[quantityinstock]"enoughstock","notenoughstock") I just dont know where to start, i didnt even know you could enter formulas in Microsoft Access so i really need help
Hi, I have another problem with my Access database now...
I am trying to disable fields when a certain value is chosen. I can do it for one field with this code:
If ALLOCATION_LP = "Other" Then OTHER_ALLOCATION_LP.Enabled = True Else OTHER_ALLOCATION_LP.Enabled = False End If
That one works perfectly well, but I have another one that needs to disable two fields instead. If they choose "No Extant PP", I want it to disable two fields; one combo box - PLNG_PERMISSION_STATUS_2 (which I can get to and it works) and also an "Other" text box - OTHER_PLNG_PERMISSION_STATUS_2 (this is where i get stuck). I have tried two If statements, but whether I'm writing them wrong, I'm not sure.
'construct a where clause as required If Nz(Me.Manufacturer.Text, "") <> "" Then Where1 = "WHERE MFRcode LIKE '*" & Me.Manufacturer.Column(0) & "*' " End If
Me.list.RowSource = _ "SELECT ID, Description, Par, MaxCoins, PayLines " & _ "FROM MachineTypeQuery " & _ Where1, Where2 & _ <- how do i get something like this to work "ORDER BY Description;"
Exit Sub Where2 comes from another control and has to be filled in before they get to this control. also "where1" and "where2" are set as public stings
I want to check eight Yes/No fields. If none of the boxes are checked I want to display a msgbox. I can link seven of the fields (no problem), when I add the eighth it doesn't work.
Am I limited to seven fields in my statement? Is there a way around this?
Any help would be appreciated.
============
If Me.Printer = 0 And Me.Hardware = 0 And Me.Software = 0 And Me.MSOffice = 0 And Me.Network = 0 And Me.NewComputer = 0 And Me.Profile = 0 And Me.Other = 0 Then
MsgBox "You must enter the type of problem(s) addressed with this customer", vbQuestion, "Type of Problem(s)"
My database has a field named "Note". This field will either have a "Y" or "N" in it. At the bottom of a report I'm writing, I want to count the number of "Y's" (not the "N's") at the bottom of my report. Can someone tell me how to do this? Thanks so much in advance!
i have a list of values that i'm trying to run through an iif, like so:
IIf(([Warehouse Location].[ToAISLE] Like "1" Or "2" Or "3" Or "4" Or "5" Or "6" Or "7" Or "8" Or "9" Or "10"),([Product Inventory with totals].[Available]+[Warehouse Location].[Qty]))
im doing that in a query, not the vb code. now heres my problem: that's not the correct syntax for the Like blah blah blah part. does anybody know the correct syntax for this?
Within my database I have 5 fields that will have either "Yes" or "No" data. I want to be able to have one of these fields look at the 4 others and if they meet a condition have the background of the field change colors.Here's a breakdown of what I'm trying to do:
Field1 Field2 Field3 Field4 Field5
Yes Yes Yes Yes No No No No No Yes
If Field5 has a "Yes" and Fields 1,2,3,4 are all "No" then I want Field 5 background to change color to indicate that a criteria was met.
Hi. I need to export a set of sql statements from my Microsoft Access database in order to put it into my new mySql server. I know that its possible to get the statements off the mysql database, but i cant figure out how to do it in microsoft access. Any help is appreciated
Hello. I have a problem implementing two separate SQL statements in dreamweaver from an Access 2003 database. The queries work fine in Access but is causing many problems in dreamweaver as they are separated.
I very much so need help in combining these two statements to form one SQL statement. Any help will be greatly appreciated. Thanks again.
SQL Statements
FIRST QUERY
SELECT tblApp.Time FROM tblApp WHERE (((tblApp.BranchID)=[Forms]![frmApp]![branch]) AND ((tblApp.Date)=[Forms]![frmApp]![date]));
SECOND QUERY
SELECT tblTime.Time FROM tblTime LEFT JOIN qryAppointmentsOnDate ON tblTime.Time = qryAppointmentsOnDate.Time WHERE (((tblTime.Branch)=[Forms]![frmApp]![branch]) AND ((qryAppointmentsOnDate.Time) Is Null));
I've got a query that is defeating me, but that might be due to a week's worth of insomnia related sleep problems. My issue exists in the following query, of the four IIF statments in the HAVING portion of the query and the need to select all if the statement is false for each one of the four queries, the way it is now partly works by returning all results where none of the values are null, I need to get null results as well. I've tried not including the false action for them, a wildcard to select all and just can't get around this problem. Any help appreciated.
SELECT DISTINCT vw_mdb_SalesSummary.Channel, vw_mdb_SalesSummary.Store_Number, [AOI Category groups].ProductType AS Category, dbo_Contact.Source_of_Inquiry, dbo_Company.Rn_Descriptor AS Store_Name, vw_mdb_SalesSummary.Job_Number, Sum(vw_mdb_SalesSummary.Extended_Price) AS Sales1, vw_mdb_SalesSummary.Designer_Code, vw_mdb_SalesSummary.Manager_Code, 0 AS Sales2
FROM ((dbo_Company RIGHT JOIN vw_mdb_SalesSummary ON dbo_Company.Store_Number = vw_mdb_SalesSummary.Store_Number) LEFT JOIN dbo_Contact ON vw_mdb_SalesSummary.Job_Number = dbo_Contact.Job_Number) LEFT JOIN [AOI Category groups] ON vw_mdb_SalesSummary.Category = [AOI Category groups].SalesCategory
WHERE (((vw_mdb_SalesSummary.Order_Date) Between [Forms]![frmLandS]![currentStart] And [Forms]![frmLandS]![currentEnd]))
GROUP BY vw_mdb_SalesSummary.Channel, vw_mdb_SalesSummary.Store_Number, [AOI Category groups].ProductType, dbo_Contact.Source_of_Inquiry, dbo_Company.Rn_Descriptor, vw_mdb_SalesSummary.Job_Number, vw_mdb_SalesSummary.Designer_Code, vw_mdb_SalesSummary.Manager_Code, 0
HAVING (((vw_mdb_SalesSummary.Channel)=IIf([Forms]![frmLandS]![Channel]<>"",[Forms]![frmLandS]![Channel],[Channel])) AND ((vw_mdb_SalesSummary.Store_Number)=IIf([Forms]![frmLandS]![Store]<>"",[Forms]![frmLandS]![Store],[vw_mdb_SalesSummary]![Store_Number])) AND (([AOI Category groups].ProductType)=IIf([Forms]![frmLandS]![AOI]<>"",[Forms]![frmLandS]![AOI],[ProductType])) AND ((dbo_Contact.Source_of_Inquiry)=IIf([Forms]![frmLandS]![source]<>"",[Forms]![frmLandS]![source],[Source_of_Inquiry])));
I have a large database with about 200 queries. I am having a problem with the last few I added. I run them from VB. When I run them the SQL statement disappears, sometimes. If I go to the SQL View instead of the Design veiw all that is left is Select;. I the Design View there is nothing.
It all works pretty much fine, however, the problem occurs because the iif statement tells the code to use either the fixed_price_list table or the price_list table depending on the value of Use_fixed. the iif works fine, its the WHERE clause. because the iif statements tell the query to look at one table or the other, the WHERE clause includes statements from both tables e.g.
queryString2 = queryString2 & " AND price_list.min_quantity <= part_select.quantity " queryString2 = queryString2 & " AND fixed_price_list.min_quantity <= part_select.quantity "
but some parts dont have information within the fixed_price_list table, and thus are not being found in the results due to the WHERE clause. can anyone help?? i tried using a left join but it didnt work how i wanted. in a perfect world i would be able to include a iif statement in the where clause e.g.
queryString2 = queryString2 & " iif Use_fixed =1, AND price_list.min_quantity <= part_select.quantity, AND fixed_price_list.min_quantity <= part_select.quantity) "
This should be simple! I'm looking at something wrong. I have two If-Else statements on the "onCurrent event of a form. ONly the first one fires. Is there something rong with the syntax???
Private Sub Form_Current()
If Me.OptInterviewed.Value = -1 Then Me.InterviewDate.Visible = True Else Me.InterviewDate.Visible = False
If Me.OrientationDate.Value = -1 Then Me.OrientationDate.Visible = True Else Me.OrientationDate.Visible = False
I have a query which works fine for one if statement, but i neewd to have 10, whats the best way of sorting this, can it be done in one query, or should i use a module or should i use the code?