Re: correct way to write the syntax for a Dlookup in a query expression in VB



On Sep 28, 8:02 pm, lyle fairfield <lyle.fairfi...@xxxxxxxxx> wrote:
On Sep 28, 3:45 am, DeZZar <derrick.goost...@xxxxxxxxx> wrote:





Hi All,

I am attempting to convert a functioning query into VB code.  I am
using a Dlookup as a formula in the query to determine if newly
imported records already exist in another table.  I want to take only
those that return false when the query runs to another table and leave
the remainder behind to be dealt with by some subsequent rules....

So my expression in part looks like this

INSERT INTO - Blagh blagh blagh
SELECT - etc etc etc
FROM - this table here......
WHERE (((IIf((DLookUp
("[QuoteNumber]","[tbl_CurrentValidations]","[QuoteNumber]=
[tbl_DailyDataImport].[LQSQuote]"))>0,'True','False'))='False'))

Of course, VBA does like all the "" in the Dlookup function when it is
part of the SQL statement for the Query, but I have attempted a
combination of ' instead of " etc and haven't had much luck.

Are there some basic conversion rules I need to follow here?

Cheers
DeZZar

I suggest:

   a) that you do not have two tables with the same structure;
   b) that you guard against duplicate entries by creating a unique
index;
   c) that you rewrite your sql select as a join checking for nulls
(we could help with that is we were swift enough to understand the
DLookup; I am not).

Others will suggest that you do not use domain functions in SQL. I
will suggest that you do not use domain functions.

Lest you become prickly, please, remember that your question and all
the thread generated by it may be shared by many.- Hide quoted text -

- Show quoted text -

not prickly at all. I am no expert at access so any advise in a
different direction is helpful.

I have two tables with a similar structure (not the same) becuase
another system pulls down information from a mainframe every morning
and deposits it as excel file. I am building this DB to import all
the new information from the excel sheet daily - but it must compare
the new data with what already exists in the database. So I import
into one table, assign a True/False in a new column based on the
Dlookup and then run further proceedures to split them up based on the
true false.

I've done it this way becuase:
a) the duplicated records cannot simply be discarded (based on Index
rules etc)
b) the duplicates may include differing information in particular
fields and the user needs to review the list and decide to either
accept the changes, or to discard and proceed.

I am building a "processing" screen which will a) import new records
b) review them (split between new and duplicated) c) have the user
review the duplicates and either accept or discard changes and d)
allow user to accept all which moves all records to the main table,
empties out the "import" table and processes each record in a loop to
create emails, system folders, generated documents and additional
field information....this all happens at the push of a button....

If anyone has a better idea please share! My ideas are based on my
limited knowledge of sql, vb and access in general! For instance, I
had no idea NOT EXISTS was a function that I could use in SQL!

Cheers
DeZZar
.



Relevant Pages

  • Re: correct way to write the syntax for a Dlookup in a query expression in VB
    ... nothing you have written indicates a need for a DLookup. ... And, just as a matter of interest, why wouldn't you use the Query Builder ... instead of writing SQL from scratch? ... the duplicates may include differing information in particular ...
    (comp.databases.ms-access)
  • Re: correct way to write the syntax for a Dlookup in a query expression in VB
    ... nothing you have written indicates a need for a DLookup. ... And, just as a matter of interest, why wouldn't you use the Query Builder ... instead of writing SQL from scratch? ... the duplicates may include differing information in particular ...
    (comp.databases.ms-access)
  • Re: comboBox & northwinds sample orders form
    ... True, but OFTEN to display a customer name when you have a customer id, we ... dlookup) are suggest. ... the problem is that you don't need dlookup in a query. ... You can always just shove in the sql in place of the ...
    (microsoft.public.access.formscoding)
  • Re: What GROUP BY is not...
    ... And if you were running it against SQL Server, ... the same amount of time for both, according to Michel (and the query ... DISTINCT is for eliminating duplicates. ... skilled users learning how to use Group By on the QBE grid will be far more ...
    (microsoft.public.access.queries)
  • Re: correct way to write the syntax for a Dlookup in a query expression in VB
    ... nothing you have written indicates a need for a DLookup. ... And, just as a matter of interest, why wouldn't you use the Query Builder ... instead of writing SQL from scratch? ... the duplicates may include differing information in particular ...
    (comp.databases.ms-access)