473,387 Members | 1,624 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.

Cancel Send Objects Command while Null Values exists in Table

36
Ok,

I have 3 stores to send a one report on click command botton. I need to write in the VBA if the store 1 is Null in the table then proceed with other.

Expand|Select|Wrap|Line Numbers
  1. Dim look As String
  2.  
  3. look = DLookup("[StoreNum]","tblStore")
  4.  
  5. IF look = "1" then
  6. DoCmd.SendObject acReport, "1", acFormatSNP, "[EmployeeName]", "[SupervisorName]", "[Subject]","[email]",
  7. Else
  8. IF look = "2" then
  9. DoCmd.SendObject acReport, "2", acFormatSNP, "[EmployeeName]", "[SupervisorName]", "[Subject]","[email]",
  10. Else
  11. IF look = "3" then
  12. DoCmd.SendObject acReport, "3", acFormatSNP, "[EmployeeName]", "[SupervisorName]", "[Subject]","[email]",
  13. End If
How I write a correct sintax for Null value store number if any store is Null then pass to the other line instruction.

Any Help?
May 14 '10 #1

✓ answered by ElTipo

@Jim Doherty
Hi Jim,

I Made this sintax for DLookup to include the criteria. If I select range in the form then provide the Stores Numbers in that range but this no working.

This is the sintax I made for DLookup:

Dim look As String

look = DLookup("[StoreNum]", "tblStore", "[ReportDate]>=#" & [Forms]![frmDateRangeStore]![BeginDate] & "# And [ReportDate] <= #" & [Forms]![frmDateRangeStore]![EndDate] & "#")

Thanks for any Help.

6 2205
Jim Doherty
897 Expert 512MB
@ElTipo
You have a choice from to types see below

Expand|Select|Wrap|Line Numbers
  1. Dim look As String
  2. 'convert any null to zero and test for 0 or zero length string
  3. look = Nz(DLookup("[StoreNum]", "tblStore"), 0)
  4. If look = 0 Or look = "" Then
  5.     MsgBox "The store num field is null or blank", vbExclamation, "Store Num Required"
  6. Exit Sub
  7. End If
  8.  
  9. Select Case look
  10. Case Is = "1"
  11.     'Your DoCmd.SendObject acReport, "1" command goes here...
  12. Case Is = "2"
  13.     'Your DoCmd.SendObject acReport, "2" command goes here...
  14. Case Is = "3"
  15.     'Your DoCmd.SendObject acReport, "3" command goes here...
  16. Case Else
  17.     MsgBox "Nothing fits the either i,2 or 3", vbInformation, "System Message"
  18. End Select
  19.  
  20. 'Choose either the above code block or the one below
  21. 'whichever is your flavour
  22.  
  23. If look = "1" Then
  24.     'Your DoCmd.SendObject acReport, "1" command goes here...
  25. ElseIf look = "2" Then
  26.     'Your DoCmd.SendObject acReport, "2" command goes here...
  27. ElseIf look = "3" Then
  28.     'Your DoCmd.SendObject acReport, "3" command goes here...
  29. Else
  30.     MsgBox "Nothing fits the either i,2 or 3", vbInformation, "System Message"
  31. End If
May 14 '10 #2
ElTipo
36
@Jim Doherty
Sorry for my late to response & my English Jim,

I try the two steps with case an if and not work really. The function goes to the else and show me only the message box and skip the do command send object. I proceed to check the data in the table and the stores numbers exists in the table.

Thanks for your time Jim,

If any idea for this please write thansk again!
Jun 24 '10 #3
Jim Doherty
897 Expert 512MB
@ElTipo
if you are looking up the value of StoreNum from a single row table called tblStore then it should work.

Does tblStore have many rows? if so you need some criteria to identify and return return the actual row you are looking up
Jun 24 '10 #4
ElTipo
36
Yes, the table have many rows..
Jun 24 '10 #5
Jim Doherty
897 Expert 512MB
@ElTipo
Well if tblStore has many rows and you are wanting to lookup and return a value from a specific row and column then the current code is very likely to fail because it is only looking for the first occurrence of any value stored in the storenum column and obviously if that value is anything other than 1 or 2 or 3 then it will fail the test .

There is nothing presented in the current code to control the WHERE aspect the CRITERIA argument of the Dlookup functionality. ie:

DLookup("[StoreNum]", "tblStore",[SomeOtherColumnField]="")

where SomeOtherColumnField is another column in your table that you pass as criteria to focus the lookup routine to targetting the row you need to examine and hence return the storenum value.

I hope I am making some sense here.
Jun 25 '10 #6
ElTipo
36
@Jim Doherty
Hi Jim,

I Made this sintax for DLookup to include the criteria. If I select range in the form then provide the Stores Numbers in that range but this no working.

This is the sintax I made for DLookup:

Dim look As String

look = DLookup("[StoreNum]", "tblStore", "[ReportDate]>=#" & [Forms]![frmDateRangeStore]![BeginDate] & "# And [ReportDate] <= #" & [Forms]![frmDateRangeStore]![EndDate] & "#")

Thanks for any Help.
Jul 30 '10 #7

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

Similar topics

9
by: Joshua Ruppert | last post by:
A section of the documentation for the isSet() function states: Also note that a NULL byte ("\0") is not equivalent to the PHP NULL constant. Where would you encounter a NULL byte? Is a null...
8
by: Boefje | last post by:
Hello, I need to get all records from a table where a for a given playerid no field enddate exists with value NULL. table player_team: id, playerid, startdate, enddate 1, ...
1
by: BadOmen | last post by:
I am using this to send am command to WinAmp and it works, The Open File(s) is opening but my program halts until I presses the Open or Cancel button. I think my program is waiting for a returned...
26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
4
by: Brendan McLoughlin | last post by:
Hi, I am looking for opinions and alternatives for handling null values in a data object which reads a record from a database table. This object will have properties which will be populated...
3
by: JOEP | last post by:
What do I need to do to allow an append query to post null values to records in a field of the destination table? Basically I want to allow records with null values to post to the table. The append...
6
by: Markus Eßmayr | last post by:
Hello, I'd like to consume a WebService, which returns an array of objects which include several members of type System.String, System.Decimal and System.DateTime. In the WSDL-file, the members...
3
by: Rodrigo C. Souza | last post by:
I need to insert a null value in a table on MS SQL Server 2000 using a stored procedure. When I send no data to the stored procedure, I get an error saying that the value cannot be null, but I did...
3
by: JM420A | last post by:
I have a query that looks like this: SELECT qryPhysicals.NAME, qryPhysicals.UPC, qryPhysicals.SSN, qryPhysicals.PhysDate, qryPhysicals.YearMo, qryPhysicals.TimeElapsed FROM qryPhysicals order by...
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
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
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
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...

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.