Hello,
I have a form from which I transfer data to access table.
The form has date, Invoice Id, Customer name and one combo box named as CmbTypeofSale which has two options 1. Cash 2. Credit
The access data table has date, Invoice Id, Customer name, Cash and Credit columns.
I want if Cash option is selected the amount should be saved in Cash column and Credit column should be blank,
and if Credit option is selected the amount should be saved in Cash column and Cash column should be blank.
How can I achieve this ?
Thanks in advance.
I have a form from which I transfer data to access table.
The form has date, Invoice Id, Customer name and one combo box named as CmbTypeofSale which has two options 1. Cash 2. Credit
The access data table has date, Invoice Id, Customer name, Cash and Credit columns.
I want if Cash option is selected the amount should be saved in Cash column and Credit column should be blank,
and if Credit option is selected the amount should be saved in Cash column and Cash column should be blank.
VB.NET:
con.Close()
Private Sub BtnSaveInvoice_Click(sender As Object, e As EventArgs) Handles BtnSaveInvoice.Click
Try
con.Open()
cmd = New OleDbCommand("Insert into TblSearchInvoice ([DateofSale],[InvoiceID],[CustomerName],[Cash],[Credit])values('" + TxtDate.Text + "','" + TxtInvoiceID.Text + "','" + CmbCustomerName.Text + "','" + CmbTypeofSale.Text + "','" + CmbTypeofSale.Text + "') ", con)
cmd.Parameters.Add(New OleDbParameter("DateofSale", CType(TxtDate.Text, Date)))
cmd.Parameters.Add(New OleDbParameter("InvoiceID", CType(TxtInvoiceID.Text, Integer)))
cmd.Parameters.Add(New OleDbParameter("CustomerName", CType(CmbCustomerName.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Cash", CType(CmbTypeofSale.Text, Integer)))
cmd.Parameters.Add(New OleDbParameter("Credit", CType(CmbTypeofSale.Text, Integer)))
cmd.ExecuteNonQuery()
cmd.Dispose()
Catch ex As Exception
MsgBox("Error", ex.Message)
Finally
con.Close()
End Try
con.Close()
End Sub
How can I achieve this ?
Thanks in advance.