DLookup and related errors

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

1. Would following Dlookup command would change previous records or only
change current record in a form :

Private Sub TicketNo_AfterUpdate()
Dim aAmt As Variant

aAmt = DLookup("[Ticket Invoice]![Amount]", "Ticket Invoice", "[Ticket
Invoice]![Ticket No]=[Ticket Cncl]![Ticket No]")

aAmt = Me![Amount]

End Sub

2. Why does many times Run time error 2001 comes with a note " U cancelled
previous operation", wheerever Dlookup command is given in before update
event or after update event of particular field.
 
A 1: Just the current row.

A 2: In the context of DLookup(), error 2001 indicates that one of the
arguments is incorrectly formed. For an explanation of how to prepare the
arguments, see:
Getting a value from a table: DLookup()
at:
http://allenbrowne.com/casu-07.html

Another suggestion might be to create a query that uses both the table for
your form and also the [Ticket Invoice] table. You can then refer to the
Amount field from the [Ticket Invoice] table in your form, without needing a
DLookup(), and it will work on all rows.

If some rows in your form have a [Ticket No], you need to use an outer join
on this query. More info:
http://allenbrowne.com/casu-02.html
 
Back
Top