Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 75
Added a column screws up code 5 63
which modules are active in VB6 project? 6 41
backup program with robocopy 6 45
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…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

856 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