Solved

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

Posted on 2003-11-06
5
562 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
Comment Utility
which line do you get the error??
0
 
LVL 5

Expert Comment

by:rajaamirapu
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now