Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 1st, 2008, 01:51 AM
Authorized User
 
Join Date: Jul 2006
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to naveed77 Send a message via Yahoo to naveed77
Default object variable not set


dear friends,
i have coding problem in da following codes which is used for saving particular record of an employee messege comes, is and please also chek the coding for saving flexgrid data

size=2]object variable or with block variable not set[/size=2]

Private Sub SaveRecord()
Dim tb1 As ADODB.Recordset
Dim tb2 As ADODB.Recordset
With tb1
    .Open "Select * From emp_personal ", db
If (.BOF And .EOF) Then
.AddNew
    tb("SrNo") = txtsrno.Text
    tb("Employee_Name") = txtename.Text
    tb("Father_Name") = txtfname.Text
    tb("N_I_C_No") = masknic.Text
    tb("Designation") = txtdesig.Text
    tb("brname") = cmbbrname.Text
    tb("dob") = dtpdob.Value
    tb("religion") = txtreligion.Text
    tb("idmark") = txtmark.Text
    tb("paddress") = txtaddress.Text
    tb("photo") = txtphoto.Text
    tb("appletter") = txtapletter.Text
    tb("appdate") = dtpltrdate.Value
    tb("pensiondate") = lblpension.Caption
    tb("disdate") = dtpdisp.Value
    tb("disdetail") = txtdetail.Text
    tb("disresult") = txtresult.Text
.Update

 tb2.Open "Select * From transfer", db
    For i = 1 To grid.Rows - 1

        .AddNew
      !station = grid.TextMatrix(i, 1)
      !fromdate = grid.TextMatrix(i, 2)
      !todate = grid.TextMatrix(i, 3)
      !duration = grid.TextMatrix(i, 4)

        .Update

    Next i
.Close
MsgBox "Record Successfully Entered", vbInformation, "CB DIK"
End If

End With

End Sub
 
Old January 1st, 2008, 01:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there...

tb1 and tb2 are dimensioned but never initialized. somewhere, before you start using it, you have to make a something like
set tb1 = new ADODB.Recordset

if you don't do that, compiler know the type of the variable, but you never really store something in it...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old January 2nd, 2008, 12:37 AM
Authorized User
 
Join Date: Jul 2006
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to naveed77 Send a message via Yahoo to naveed77
Default

dear gibianchi, thnq v.much it really works nice rite after ur correction, thnq again,





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object variable or With block variable not set I_Chappers ASP.NET 2.0 Basics 3 June 26th, 2008 04:15 PM
Object variable or With block variable not set haidee_mccaffrey Classic ASP Professional 5 March 8th, 2007 03:34 PM
Object Variable or With Block Variable not Set Parbish BOOK: Beginning VB.NET Databases 5 July 13th, 2005 04:03 AM
Object variable or with block variable not set spacy ASP.NET 1.x and 2.0 Application Design 0 September 21st, 2004 12:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.