Y problem always continue???

C

cjnow

From this: http://www.msusenet.com/t-1870476078.html

Hi, im really new to access..i got problem again...

Invoice form split to header and details(2 diff tables).And customer i
another table.

How can i limit the purchase in the invoice form, in between tha
particular month, and with the same customer no. where should i put th
command and how to write the command? do u understand wat i mean ? sorr
for my poor english. hope u understand.


This is wat i done,but the problem still occur, maybe is the coding, i
very frus with it....im too stupid..

Private Sub save_LostFocus()

Dim sum_amt As String
Dim msg As String
Dim sqlstr1 As String
Dim sqlstr2 As String

Dim db1 As Database
Dim RS1 As Recordset

sqlstr1 = " SELECT DISTINCTROW [Invoic
Details].[d_inv_cust_code],[Invoice Details].[amount],[Invoic
Details].[ddd] ,[Invoice Details].[mmm] , [Invoic
Details].[yyy],[Customer].[Purc_limit] FROM [Invoice Details] INNE
JOIN [Customer] on [Invoice Details].[d_inv_cust_code]=Forms![Invoic
Details1]![cust code] AND [Invoice Details].[mmm]=Forms![Invoic
Details1]![m] ;"

'[Invoice Details] table fields:
'd_inv_code
'd_inv_cust_code
'd_p_code
'amount

sqlstr2 = "SELECT sum ([RS1!amount])AS [sqlsum] FROM [sqltable1];"


Set db1 = DBEngine.Workspaces(0).Databases(0)

Set RS1 = db1.OpenRecordset(sqlstr1, DB_OPEN_TABLE)

'sum_amt = sum([RS1!amount])
DoCmd.RunSQL (sqlstr2)
sum_amt = sqlsum

If sum_amt > [Customer].[Purc_limit] Then msg = MsgBox("Ove
Purchase limit", vbOKCancel)

'sum up all the sub amount first for the month in a variable le
say dim sum_amt
'compare the sum amount with limit of the customer--> take fro
customer form

End Sub


I think is my coding prob, the logic is there rite? Im new in VBA. An
one can help?
 
Top