pak Dann_ist,
kalau mau mencegah duplikasi bisa dimulai dari setting field KodeBarang dan
NamaBarang di database di set index = Yes (no duplicate)
dan
anda bisa lihat di Access Help sbb:
DCount(expr, domain, [criteria])
The DCount function has the following arguments.
Argument Description
expr An expression that identifies the field for which you want to count
records. It can be a string expression identifying a field in a table or query,
or it can be an expression that performs a calculation on data in that field.
In expr, you can include the name of a field in a table, a control on a form, a
constant, or a function. If expr includes a function, it can be either built-in
or user-defined, but not another domain aggregate or SQL aggregate function.
domain A string expression identifying the set of records that
constitutes the domain. It can be a table name or a query name for a query that
does not require a parameter.
criteria An optional string expression used to restrict the range of data
on which the DCount function is performed. For example, criteria is often
equivalent to the WHERE clause in an SQL expression, without the word WHERE. If
criteria is omitted, the DCount function evaluates expr against the entire
domain. Any field that is included in criteria must also be a field in domain;
otherwise the DCount function returns a Null.
Remarks
Use the DCount function to count the number of records in a domain when you
don't need to know their particular values. Although the expr argument can
perform a calculation on a field, the DCount function simply tallies the number
of records. The value of any calculation performed by expr is unavailable.
Use the DCount function in a calculated control when you need to specify
criteria to restrict the range of data on which the function is performed. For
example, to display the number of orders to be shipped to California, set the
ControlSource property of a text box to the following expression:
=DCount("[OrderID]", "Orders", "[ShipRegion] = 'CA'")
(artinya: Banyaknya baris di kolom OrderID dari tabel Orders dimana
ShipRegionnya adalah CA)
=Dcount("kodebarang","tbBarang","[kodebarang]='" & Forms!frmBarang!kodeBarang &
"'")
(artinya hitung banyaknya baris di kolom kodebarang dari tabel tbBarang dimana
kodebarang sama dengan yang ditulis di form frmBarang textbox kodebarang.)
mungkin bisa ditambahkan dgn :
.value --> Forms!frmBarang!kodeBarang.value
atau
.text ---> Forms!frmBarang!kodeBarang.text
salam kompak dan jabat erat,
MBA
----- Original Message -----
From: "dann_ist" <[email protected]>
To: <[email protected]>
Sent: Monday, June 22, 2009 04:39
Subject: [belajar-access] Re: Duplikasi file
> belum berhasil syntax nya mas MBA.. klo syntax default nya gimana sih? saya
> bingung di :
>
> jKode = DCount("kodebarang", "tbbarang", "[kodebarang]= '" &
> Forms!frmBarang!kodeBarang & "'")
> (kodebarang ada2) trus apakah baris atas pake dim dcount as a string
>
> mungkin klo bisa dijelaskan dalam bahasa indonesia cara kerja syntax di atas.
> terima kasih