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

Quick help with SQL command in VB

27
I am having problems with using the IIf/dlookup command in my recordsource query. Is it possible to use this within VB? it works as a regular query. I tried to fix the quotes, etc, but it didn't seem to fix the problem.

Expand|Select|Wrap|Line Numbers
  1. me.form.recordsource = "SELECT [Table].[Number], [Table].[SubNumber], " & _
  2.         "IIf(nz(DLookUp('[ID]','Revisions','[Number] = '" & _
  3.         "[Table]![Number] & "''),False)<>False,True,False) AS Test " & _
  4.         ....and so on

Thanks!
Feb 2 '07 #1
3 1535
MMcCarthy
14,534 Expert Mod 8TB
Firstly, you are trying to impose a boolean value of False into the ID field if null value exists. You can't do this.

If [Table]![Number] is a number datatype then remove the quotes and change the code as follows:

Expand|Select|Wrap|Line Numbers
  1. me.recordsource = "SELECT [Table].[Number], [Table].[SubNumber], IIf(nz(DLookUp('[ID]','Revisions','[Number]=" & [Table]![Number]),0) <>0,True,False) AS Test " & _ ....and so on
  2.  
However, if it is a string datatype you will need the following:

Expand|Select|Wrap|Line Numbers
  1. me.recordsource = "SELECT [Table].[Number], [Table].[SubNumber], IIf(nz(DLookUp('[ID]','Revisions','[Number]='" & [Table]![Number] & "'')," ")<>" ",True,False) AS Test " & _ ....and so on
  2.  
Feb 3 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
BTW, you don't need to use ...

Expand|Select|Wrap|Line Numbers
  1. Me.Form.Recordsource=
Me. designates the form so you only need ...

Expand|Select|Wrap|Line Numbers
  1. Me.Recordsource=
Feb 3 '07 #3
NeoPa
32,556 Expert Mod 16PB
I think you may be looking for something more like this, if I'm right in suspecting that you're trying to build up the DLookup function call from within the SQL code.
You had a single-single-quote after ('[Number] = ) rather than a double-single-quote which would have been required.
Expand|Select|Wrap|Line Numbers
  1. Me.RecordSource =
  2.     "SELECT [Table].[Number], [Table].[SubNumber], " & _
  3.     "IIf(Nz(DLookUp('[ID]','Revisions','[Number] = " & _
  4.     "'' & [Table]![Number] & ''),False)<>False,True,False) AS Test " & _
  5.     ....and so on
A better way would probably be to link the tables with a LEFT JOIN (Table & Revisions).
Let me know if I'm off track, but I'm guessing this is what you were trying to do.
Feb 4 '07 #4

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

Similar topics

15
by: Ron Adam | last post by:
Does anyone have suggestions on how to improve this further? Cheers, Ron_Adam def getobjs(object, dlist=, lvl=0, maxlevel=1): """ Retrieve a list of sub objects from an object. """
3
by: Carter | last post by:
How do you make the output of a c++ program be interpreted as a UNIX command? Example, what would a program that executed ls look like?
8
by: Menon | last post by:
Hi folks I am not at all an SQL server guy (more of an Oracle developer.) I wanted to know if you guys could tell me if SQL Server supports objects in the database. If so, could you kindly point...
7
by: ZRexRider | last post by:
Hi, I'm developing an application that runs on laptops that periodically connect to network. I am collecting data in local tables within the MDB. I want to recognize the occasional network...
2
by: Brent Morgon | last post by:
Hello-- Very quick question from a very new ASP.Net developer, or soon to be developer.. whatever. I've installed the 1.1 Framework onto a W2K Pro box with IIS 5.0 installed all with default...
3
by: SteveInBeloit | last post by:
hi, I have a small vb.net app that runs on a handheld device running CE. Using Visual Studio. I have decided I want to have then user enter a user name when it starts up. Is there a quick input...
1
by: johndoyle | last post by:
I've seen a few posts on other sites discussing how to save an excel file, word file, or other office doc as a pdf document. In general, seems the solutions have been pretty complicated or...
5
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
3
digicrowd
by: digicrowd | last post by:
http://bytes.com/images/howtos/applemail_sig_icon.jpg You can make your emails fancy in Mail.app by using Rich Text formatting or even included Stationery. But, a simple way to send your own HTML...
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: 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
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:
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...

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.