Error......

aks6190

Registered User.
Local time
Today, 16:42
Joined
Feb 23, 2011
Messages
10
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset

Private Sub cmdAdd_Click()
DataGrid1.Visible = True
cmdSave.Enabled = True
txtBookorderid.Enabled = True
enablerec
clearrec
MsgBox "You can add new record", vbOKOnly + vbInformation
Set rs = New ADODB.Recordset
rs.Open "Customer_order", con, adOpenDynamic, adLockOptimistic, adCmdTable
If rs.BOF And rs.EOF Then
no = "1"
Else
rs.MoveLast
no = Trim(rs(1)) + 1
End If
txtBookorderid.Text = no
txtBookorderid.Enabled = False
txtCustname.SetFocus
End Sub

Private Sub cmdCancel_Click()
If txtCustname.Text = "" Then
txtAddress.Text = ""
txtCustmobile.Text = ""
txtEmail.Text = ""
txtBookname.Text = ""
txtAuthor.Text = ""
txtQuantity.Text = ""
txtAdvancepay.Text = ""
MsgBox "You are trying to clear empty fields!", vbInformation
txtCustname.SetFocus
Exit Sub
End If
clearrec
End Sub




Private Sub cmdExit_Click()
Dim p As String
p = MsgBox(" Do you want to exit? ", vbYesNo + vbInformation)
If p = vbYes Then
Unload Me
Else
frmCustomerorder.Show
End If
End Sub

Private Sub cmdSave_Click()

If txtCustname.Text = "" Or txtAddress.Text = "" Or txtCustmobile.Text = "" Or txtEmail.Text = "" Or txtBookname.Text = "" Or txtAuthor.Text = "" Or txtQuantity.Text = "" Or txtAdvancepay.Text = "" Then
MsgBox "Empty fields!Enter appropriate data", vbInformation
Else
rs.AddNew
rs("Cust_order_date") = DTPicker1.Value
rs("Bookorder_id") = txtBookorderid.Text
rs("Cust_name") = txtCustname.Text
rs("Cust_address") = txtAddress.Text
rs("Mobile_no") = txtCustmobile.Text
rs("Email") = txtEmail.Text
rs("Advance_pay") = txtAdvancepay.Text
rs("Expected_date") = DTPicker2.Value
rs.Update

rs1.Open "SELECT * FROM Customer_book_order_details where Bookorder_id=' " & txtBookorderid.Text & " ' ", con, adOpenDynamic, adLockPessimistic
Set res1 = New ADODB.Recordset
rs1.AddNew
rs1("Bookorder_id") = txtBookorderid.Text
rs1("Bookname") = txtBookname.Text
rs1("Author") = txtAuthor.Text
rs1("Quantity") = txtQuantity.Text
rs1.Update
MsgBox "Record is saved", vbOKOnly + vbInformation
End If
End Sub

Private Sub Form_Load()
Dim rs1 As New ADODB.Recordset
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.Provider = "Microsoft.Jet.OLEDB.4.0"
con.Open App.Path & "\Bookshop.mdb"

rs.ActiveConnection = con
rs.CursorLocation = adUseClient
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Open "SELECT * FROM Customer_order"



Set rs1 = New ADODB.Recordset
rs1.ActiveConnection = con
rs1.CursorLocation = adUseClient
rs1.CursorType = adOpenDynamic
rs1.LockType = adLockOptimistic
rs1.Open "SELECT * FROM Customer_book_order_details"

Set DataGrid1.DataSource = rs1
DataGrid1.Visible = True
cmdSave.Enabled = False
txtBookorderid.Enabled = False
cmdCancel.Enabled = False
End Sub




Private Sub clearrec()
txtBookorderid.Text = ""
txtCustname.Text = ""
txtAddress.Text = ""
txtCustmobile.Text = ""
txtEmail.Text = ""
txtBookname.Text = ""
txtAuthor.Text = ""
txtQuantity.Text = ""
txtAdvancepay.Text = ""
End Sub



Public Sub enablerec()
txtBookorderid.Locked = False
txtCustname.Locked = False
txtAddress.Locked = False
txtCustmobile.Locked = False
txtEmail.Locked = False
txtBookname.Locked = False
txtAuthor.Locked = False
txtQuantity.Locked = False
txtAdvancepay.Locked = False
End Sub







Private Sub txtAdvancepay_KeyPress(KeyAscii As Integer)
Call number(KeyAscii)
End Sub

Private Sub txtAdvancepay_LostFocus()
If txtAdvancepay.Text = "0" Then
MsgBox "Incorrect value", vbCritical
txtAdvancepay.Text = ""
End If
End Sub

Private Sub txtAuthor_KeyPress(KeyAscii As Integer)
Call alpha(KeyAscii)
End Sub


Private Sub txtCustmobile_KeyPress(KeyAscii As Integer)
Call number(KeyAscii)
End Sub



Private Sub txtCustmobile_LostFocus()
If Len(txtCustmobile.Text) < 10 Then
MsgBox "Enter valid mobile number", vbCritical
txtCustmobile.Text = ""
End If
If txtCustmobile.Text = "0" Then
MsgBox "Incorrect value", vbCritical
txtCustmobile.Text = ""
End If
End Sub

Private Sub txtCustname_Change()
If txtCustname.Text <> "" Then
cmdCancel.Enabled = True
End If
End Sub

Private Sub txtCustname_KeyPress(KeyAscii As Integer)
Call alpha(KeyAscii)
End Sub



Private Sub txtQuantity_KeyPress(KeyAscii As Integer)
Call number(KeyAscii)
End Sub

i am not able to enter data into datagrid when i press on save button!..
it is giving me error "runtime error 7004 the rowset is not bookmarkable!...
plz help
i am using VB 6 and MS Access 2007
 
have to ask....
is there a PK in the table you are trying to Insert into or update?
 
have to ask....
is there a PK in the table you are trying to Insert into or update?
here i m trying to use two tables first table has PK and second table has FK which is Bookorderid i want to enter the data from second table into datagrid......the first and second tables are opened using rs and rs1.
 
here i m trying to use two tables first table has PK and second table has FK which is Bookorderid i want to enter the data from second table into datagrid......the first and second tables are opened using rs and rs1.
thanks!....
 
Please use code tags when posting code (especially large bits of it)

codetag001.png
 

Users who are viewing this thread

Back
Top Bottom