inserting record from form 
Author Message
 inserting record from form

Pleas can anyone help?
I have a form that for various reasons I can not connect directly to a
datasource. I have a button where the OnClick event performs various
functions including the one below. It all seems to work fine apart for the
'CustomerReceiptDate'.

The event procedure runs without any problems but the date inserted into the
table is not the date on the form. It appears to be a time and shows in the
table as 31/12/1899.

I have checked the format in the form and table but am getting frustrated.

Thanks in advance

Marcus Armand

dbs.Execute "INSERT INTO tblSalesLedgerreceipts(BankAccount,
CustomerReceiptDate, CustomerReceiptRef, CustomerID, Description, Amount,
Reconciled, AmountPaid, Posted) SELECT " & stBankAccount & ", " &
CDate(stSalesPaymentDate) & ", " & stSalesPaymentRef & ", " & stCustomerID &
", 'Sales Receipt', " & stAmounta & ", 0, " & stAmountPaid & ", 0;",
dbFailOnError



Sun, 09 Oct 2005 05:18:02 GMT  
 inserting record from form
You need to delimit the date value with # signs and it needs to be in US format
of MM/DD/YYYY.  Try the following:

dbs.Execute "INSERT INTO tblSalesLedgerreceipts(BankAccount,
CustomerReceiptDate, CustomerReceiptRef, CustomerID, Description, Amount,
Reconciled, AmountPaid, Posted) SELECT " & stBankAccount & ", " &
Format(CDate(stSalesPaymentDate),"\#mm\/dd\/yyyy\#") &
", " & stSalesPaymentRef & ", " & stCustomerID &
", 'Sales Receipt', " & stAmounta & ", 0, " & stAmountPaid & ", 0;",
dbFailOnError

Quote:

> Pleas can anyone help?
> I have a form that for various reasons I can not connect directly to a
> datasource. I have a button where the OnClick event performs various
> functions including the one below. It all seems to work fine apart for the
> 'CustomerReceiptDate'.

> The event procedure runs without any problems but the date inserted into the
> table is not the date on the form. It appears to be a time and shows in the
> table as 31/12/1899.

> I have checked the format in the form and table but am getting frustrated.

> Thanks in advance

> Marcus Armand

> dbs.Execute "INSERT INTO tblSalesLedgerreceipts(BankAccount,
> CustomerReceiptDate, CustomerReceiptRef, CustomerID, Description, Amount,
> Reconciled, AmountPaid, Posted) SELECT " & stBankAccount & ", " &
> CDate(stSalesPaymentDate) & ", " & stSalesPaymentRef & ", " & stCustomerID &
> ", 'Sales Receipt', " & stAmounta & ", 0, " & stAmountPaid & ", 0;",
> dbFailOnError



Sun, 09 Oct 2005 07:09:22 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. need ID from newly inserted record (altered by insert trigger on SQL server)

2. Inserting a new record between existing records?

3. Inserting a new record between existing records?

4. going to next record after inserting a new record

5. record locking while insert new record??

6. Problem with format on insert autotext, and in inserting elements with form fields

7. Insert text from form into another form

8. Function to seek record and make current record on form

9. Copy Form records and Subform records....

10. Inserting a record, error message appears.

11. Trap error when inserting a record

12. Using DAO to insert records

 

 
Powered by phpBB® Forum Software