msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

object variable or with block variable not set

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise
Author Message
nick



Joined: 18 Oct 2007
Posts: 12

PostPosted: Thu Oct 18, 2007 9:58 am    Post subject: object variable or with block variable not set Reply with quote

Hello,,

Iam just trying to read a sheet from excel and transfer that excel
information into my Access database.

When i try to import the excel data Iam getting Object variable or with
block variable not set...

Iam using VB6.0 and Ms-Access .

The folloiw is my code

Dim rs2 As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
Private Sub cmdBrowse_Click()
cmndFilePath.CancelError = True
cmndFilePath.Filter = "Databases|*.XLS"
On Error Resume Next
cmndFilePath.ShowOpen
Data1.DatabaseName = cmndFilePath.FileName
txtFilePath.Text = cmndFilePath.FileName
Data1.Refresh
End Sub
Private Sub cmdImport_Click()
If Data1.RecordSource "Sheet1$" Then
MsgBox "Invalid Sheet"
Exit Sub
Else
Set rs2 = Nothing
rs2.Open "Select * from TrackingDetails ", con, adOpenKeyset, 2

While Not Data1.Recordset.EOF
rs2.AddNew
rs2(0) = Data1.Recordset(1)
rs2(1) = Data1.Recordset(2)
rs2.Update
Data1.Recordset.MoveNext
Wend
End If
MsgBox "Transferred completely"

Call Display
End Sub
Public Sub Display()
'Set rs1 = New Recordset
rs1.Open "select * from TrackingDetails", con, adOpenStatic,
adLockOptimistic
Set DataGrid1.DataSource = rs1
End Sub

Private Sub Form_Load()
Call GetConn
End Sub


The below code isin Differnt module

Public con As ADODB.Connection
'Public con As New ADODB.Connection
Public Sub GetConn()
Set con = New ADODB.Connection
Dim dbname As String
dbname = App.Path & "\TrackingStatus.mdb"
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
dbname & ";Persist Security Info=False"
con.Open
End Sub



Can anyone help me in solving the above said problem???

Thanks and Regards
Nick,

Archived from group: microsoft>public>vb>enterprise
Back to top
View user's profile Send private message
Bob Butler



Joined: 04 Oct 2007
Posts: 1081

PostPosted: Thu Oct 18, 2007 10:17 am    Post subject: Re: object variable or with block variable not set Reply with quote

"nick" wrote in message @microsoft.com...
> Hello,,
>

please do not multipost questions. If you must ask in multiple newsgroups
then list them all at the same time so that answers to one appear for all.

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
how to show a form using variable ? Is it possible to show a form using name in variable. For example: a="Form1" &a.show I also tried forms(a).show but could not succeed. I am using MDI Environment, and need this to show child forms, names of which are saved in a table. Any idea please ? Be

passing a variable as an attachment to outlook If I call this works fine = object doesn't support this property or method if I debug contains the correct information.

formatting text within a String variable? If I want a String variable to display some of the font as underlined or bold, am I out of luck? For example: Private Type Question QuestionText As String AText As String BText As String 'etc. 'and other items in this used-defined type End Type Private Qu

Passing Variable Data From One Form to Another (and opening I want to open a dialog on startup that will ask for the user to select a chapter number When the chapter is selected, I want to close the dialog and go to the main form with this chapter number in a variable called chapter. I just

problem whit WINSOCK that Block VB6 at the end [Exuse me for language, I'm Italian] I can't use Winsock whit my application in VB6, because everytime I stop my application, it block VB6, and I must restart VB6 everytime. I have reinstall VB6 and SP3,4,5 but the problem there is again. How can I do ???
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group