Solved

FlexGrid error message (Object Variable or With Block Variable not set)

Posted on 2003-11-06
5
594 Views
Last Modified: 2013-12-26


I have successfully added a DataGrid to my form wusing the code listed below.  I am trying to see if a FlexGrid will provide more flexibility for formatting a'la .net style (this is in VB6).

Can anyone tell me why I an getting an object variable or with block variable not set?  Does it make sense to switch to FlexGrid?  Also I have a click event to set the first field as Yes or No so that I can use it for another action later.  Will that preclude me from using the FlexGrid?

Function GridFill(clientid, reloadType)

    allclientQRY = "exec ReRun_GetSamples " & "'" & clientid & "'" & ", '" & reloadType & "'"
         
    Set samples = MyConnection.Execute(allclientQRY)

    Dim GridData As ADODB.Recordset

    Set GridData = New ADODB.Recordset

    GridData.Fields.Append "ReRun?", adBoolean, , adFldIsNullable
    GridData.Fields.Append "SampleID", adInteger, 64
    GridData.Fields.Append "Sample Number", adBSTR, 64
    GridData.Fields.Append "Tray Number", adBSTR, 64
    GridData.Fields.Append "Well Number", adBSTR, 64
    GridData.Fields.Append "Reload Type", adBSTR, 8
    GridData.Open
   
    If Not samples.EOF Then
        lblNoGrid.Visible = False
        DataGrid1.Visible = True
   
        samples.MoveFirst
       
        Do While Not samples.EOF
            GridData.AddNew
            GridData.Fields("ReRun?").Value = False
            GridData.Fields("SampleID").Value = samples(0)
            GridData.Fields("Sample Number").Value = samples(1)
            GridData.Fields("Tray Number").Value = samples(2)
            GridData.Fields("Well Number").Value = samples(3)
            GridData.Fields("Reload Type").Value = reloadType
            GridData.Update
            samples.MoveNext
        Loop

        Set DataGrid1.DataSource = GridData
               
        ' Set up Boolean Formatting
       
        With DataGrid1
            '.Columns(1).Locked = True
            Set fmtBooleanData = New StdDataFormat
            fmtBooleanData.Type = fmtBoolean
            fmtBooleanData.TrueValue = "Yes"
            fmtBooleanData.FalseValue = "No"
            fmtBooleanData.NullValue = "No"
            Set .Columns("ReRun?").DataFormat = fmtBooleanData
        End With
0
Comment
Question by:BodeTech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 9699201
which line do you get the error??
0
 
LVL 5

Expert Comment

by:rajaamirapu
ID: 9699580
Have removed DataGrid1 control from the form or it is still there.
If you have removed  DataGrid1 then i suspect the problem is with DataGrid1
HTH
Raja sekhar
0
 
LVL 1

Accepted Solution

by:
KeyPakt earned 500 total points
ID: 9700881
I think your problem might be that you have not actually connected your ADODB.Recordset to any datasorce so when you try to set your DataGrid1.DataSource to the GridData there are nothing to connect to. If you want to connect your Grid to a datasource this information must come either from a query or a table that you have stored in your database. You you try to set the datasource of your datagrid to your sample connection you will see that it works.
0
 

Author Comment

by:BodeTech
ID: 10431650
Sorry for the delay!!!!!!!!!!!!!!!!!!!

I did not realize that I had failed to close this out.  I was pulled ot another project and had no visibility to this for a while.  Thanks for the help.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question