Solved

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

Posted on 2003-11-06
5
588 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to compare ms sql hashbytes results within vb6 5 97
Help me. 3 69
IF ELSE Statement in Excel Macro VBA 16 87
Formula problem with Excel attachment 6 43
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

749 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