Solved

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

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

623 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