Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Msflexgrid CellBackColor


I can use the msflexgrid pretty well except for one little think I can't add a color to a specific cell and I have no idea how to do it?

I tried many different combinations but couldn't get it to work. So here is my question before I put anyone to sleep with my ranting.

If I want to change the color of one specific cell how do I go about doing that? How to give it the cordinates so it know which one I want to change?

Thank you!


PS: This has been driving nutz!

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
MSFlexGrid's CellBackColor
Hello Everyone,

I am using a MSFlexGrid and want to change the colors of some cells. I am using a floating textbox so to act like the flexgrid is editable. What I want to do is look at what the user enters into the textbox when placed over the first column of the grid and based on what they enter I want certain cells in that same row to change color. I want some cells to change to a different colors to show if the input for that cell is optional or if it is N/A and not to place any input in those cells. My problem is that I have to loop through the remaining cells and set the .CellBackColor of that cell. I do not like using this loop to move to that cell because I do not like the looks of the way it jumps around. I even turn Redraw off until I set all of the cells, but it still seems to have an obvious jump. I was wondering if there was anyway to set the color of individual cells without having to move to each cell to set the color. Any suggestions?

Thanks in advance.

Retrieving The CellBackColor Of A MSFlexGrid
I have a grid that values are entered into. When a command button is pressed, a copy of the data is sent elsewhere. To keep track of which values have been copied, I set the CellBackColor to dark green and the CellForeColor to white.

Before I close the application, I want to check to make sure all values have been copied. If a cell has text, but the CellBackColor is white, I know it hasn't been copied. I wrote the following code. The problem is that the CellBackColor returns a value of 0, meaning that although a cell has text, it doesn't recognize that the back color is white. Can someone point out what I'm doing wrong.
For i = 0 To 1
With frmMain.mfgRunTank(i)
For lngRow = 2 To .Rows - 1
For lngCol = 1 To .Cols - 1
If .TextMatrix(lngRow, lngCol) <> "" Then
.row = lngRow
.col = lngCol
If .CellBackColor = vbWhite Then
End If
End If
Next lngCol
Next lngRow
End With
Next i

MSFlexGrid Retrieving Actual CellBackColor
I'm getting a big fat zero (which, I believe, is the default or something) when I try to retrieve the .CellBackColor property of my flexgrid - any tricks to get the ACTUAL colour?

Change CellBackColor, FontStyle, FontColor In MsFlexGrid
I want to Change CellBackColor, FontStyle, FontColor in MsFlexGrid

plz help me

FlexGrid CellBackColor
I'm trying to change the backcolor of a cell to black. i can get it to change to any other color but black.

I've tried this and it worked to change it to blue:
msgGrid.CellBackColor = vbBlue

msgGrid.CellBackColor = vbBlack doesn't work.

any ideas?

Integer Value Of .cellbackcolor
i have an msh flexgrid and the code below:

Dim Number As Double

with mshflexgrid1

if .cellbackcolor = Number then
end if

end with

Even when I the situation has to be true, the pgm does not enter the id statement...I have even tried val(.cellbackcolor) there anything else...

actually instead of Number I have Color as a field in an access it's really .cellbackcolor = val(rs!Color)...but the concept is the same...the val(rs!Color) it's .cellbackcolor...




CellBackColor On FlexGrid
Has anyone figured out how to set the backcolor of a cell in the FlexGrid without moving focus to the grid?

I wish I could do FlexGrid1.TextMatrix(3,4).CellBackColor=RGB(0,0,0)

The reason this is such a problem is that I have a grid that is updating all the time and if someone has say a combo box pulled down and the grid needs to change a color it closes up the combo box.

I really don't think it can be done but thought I'd toss it out there.

FlexGrid CellBackColor Property
Hi there...

I'm quite new to both coding and to XtremeVBTalk.

My query relates to the FlexGrid component. I am trying to set the background colour of a specific cell in the matrix, but I don't seem to be able to do it. when I use the flexgrid.cellbackcolor property it sets the colour in the same cell (1,1) every time, and I can't seem to find a way of programatically focusing on the specific cell I want to adjust. I spose it's one of those easy things when you know how, but I've examined/tried every property available with no success. any pointers??

Cheers, Jex.

CellBackColor Changes On Grid Refresh
Is there a way to keep the cell back color from changing back to the default when refreshing the grid other than repainting the cells?

Saving Cellbackcolor On Exit
I have written code to color the grid cell yellow to highlight that the data has changed, however once the form is closed or refreshed the cell color goes back to default. How can i store the cell color before the form closes for each cell, preferably without running a loop procedure for every cell which will increase shutdown time, but preferably at the time when the cellcolor is changed.

Quite Weird Flxgrid.cellbackcolor = Lbl.backcolor
if u set the backcolor of a flxgrid cell to a lables backcolor it will work for every colour except for Black

anyone care to tell me why?

(ie flxgrid.CellBackColor = lblColour(mC_NOTAVAILABLE).BackColor)

Reading Cellbackcolor Problem In Flexgrid
I’m having problems reading the CellBackColor of a flexgrid in certain situations.

If I’m using the click event on the grid, I am able to read the color
    ex. If MSFlexGrid1.CellBackColor = vbRed Then
        ‘this will return true if the cell clicked is red

However when I try to reference by a certain row and column, it always returns false and the CellBackColor is always 0.
     With MSFlexGrid2
        .Row = 1
        .Col = 0
        if .CellBackColor = vbRed then
    ‘this is always returning false

Any ideas on how to do this?

Thanks in advance,


Transfer Of Data From Msflexgrid To Another Msflexgrid
     how can i transfer the values of first row of Msflexgrid1 to first row of Msflexgrid2 placed in parallel of 1st one .

Moved from Code Bank - VB6 to VB General forum

Edited by - djjeavons on 2/19/2006 1:48:00 AM

Copy From Msflexgrid To Msflexgrid And Save Changes
I have created a data environment with a connection to a microsoft access database. Under my command for my table I created another command for another table with a relationship child/parent using the eventnumber field. This works great and shows the assignedvehicles compared to the eventnumber field on my form. What I am trying to do is add another msflexgrid that will show the availablevehicles and be able to drag one to the assignedvehicles and save. The problem I am having is saving the record when dragged. I have used code I got from a post from Chris Eastwood. Some of the fields are different and I only need to drag some of the fields not all.

I just wanted to know is it possible to select few row's in MSFlexgrid and drop them into another MSFlexgrid, or do i need to copy the selected rows to clipboard and paste them latter into another flex grid. can you give me an idea.

Txt To MSFlexgrid To Graph To MSFlexgrid

I'm a beginner with a project in the works and am stuck on the following, any help would be much appreciated:

I am importing a comma delimited TXT file using chunks, then splitting the chunks into seperate strings, filtering the strings to match a certain criteria and then dumping these strings into an MSFlexgrid using the addrow option.

the data is in the follwing format in the msflexgrid

bb, xx, yy, zz

what I'm trying to do is to run a query on the msflexgrid which will provide me with the average sqrt of (xx sqr + yy sqr) when the zz values are the same and then dump this value out to another msflexgrid with the zz value to which it applies ie

the average squareroot of the sum of the square of xx and yy equals "a" when zz equals "b" and so on for whatever values of zz occur within the msflexgrid.

A bit confusing I know but I don't know how else to explain it.

In addition to this I also want to display the xx, yy, zz values from the msflexgrid on an xy scatter chart.

Any help would be really appreciated as I'm stumped and my book doesn't help.


Tee Jay

How can I restrict the no of characters typed in a flexgrid cell?

Please help




Is there someway to change or modify some of the cells within the MSFlexGrid table to ComboBox.



I am trying to perform some operations like selecting a row and reflecting those values into text boxes...How do I refer to the selected column in the grid...Could you please help me....


Hi all

Thanks in advance

How to set single column selection msflexgrid control
through coding or runtime

Now there is a form with a msflexgrid(scrollbars),a Data and a timer. The msflexgrid has been binded with Data. The data will refresh each second using the timer. Then there is a question...
Because the data source has many data columns, the msflexgrid has a horizon scrollbar automatically. When I click the scroll bar, the data of the msflexgrid will scroll.But when the data refreshed, the scroll bar will go back to the beginning spot. I wonder if there is certain method can remember the current spot of the scroll and keep the msflexgrid consistent.
Please help me!

When I bind a MsFlexGrid with a Data source, the data topic will present in the top line of the MsflexGrid. Now there is a question...
I wonder if there is a method that can let the topic present in the first column!
Please help me!

how do i know which cells were selectd in multiple selecting
by the user in msflexgrid

for example i want all the selected cells will get the text "11"


Does anyone know of a way to set the width of each cell in the MSFlex grid programatically? The colwidth property is only able to return the current width. I'd like to be able to have differing widths for my data without making the user set them themselves.

I'm using the MSflexgrid in my game but I'm finding it a little slow to update, 10x10 grid. Dose anyone have any ways to help speed this up or even a better control that the MSflexgrid.

I'm also having a problem with the focusrect property, if I set it to flexfocusnone then I need to set a color which then overwrites what I already have in the cell, I would like to be able the select a cell and have nothing displayed unless I decide to set the cellbackground color.

A little aggravating!! hehe



I use msflexgrid in my program when I use of mergecell property in my code dont work backcolorsel propety this is my code. can anybody help me ?
Private Sub Form_Activate()
Me.MSFlexGrid1.Redraw = False
Me.MSFlexGrid1.ColWidth(13) = 2050
Me.MSFlexGrid1.ColWidth(5) = 700
Me.MSFlexGrid1.ColWidth(6) = 700
Me.MSFlexGrid1.ColAlignment(0) = 1
Me.MSFlexGrid1.ColAlignment(1) = 1
Me.MSFlexGrid1.ColAlignment(2) = 1
Me.MSFlexGrid1.ColAlignment(3) = 1
Me.MSFlexGrid1.ColAlignment(4) = 1
Me.MSFlexGrid1.ColAlignment(5) = 1
Me.MSFlexGrid1.ColAlignment(6) = 1
Me.MSFlexGrid1.ColAlignment(7) = 1
Me.MSFlexGrid1.ColAlignment(8) = 1
Me.MSFlexGrid1.ColAlignment(9) = 1
Me.MSFlexGrid1.ColAlignment(10) = 1
Me.MSFlexGrid1.ColAlignment(11) = 1
Me.MSFlexGrid1.ColAlignment(12) = 1
Me.MSFlexGrid1.ColAlignment(13) = 1
Me.MSFlexGrid1.TextMatrix(0, 0) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 1) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 2) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 3) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 4) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 5) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 6) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 7) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 8) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 9) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 10) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 11) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 12) = " Ș "
Me.MSFlexGrid1.TextMatrix(0, 13) = " Ș "
MSFlexGrid1.MergeCells = flexMergeFree
MSFlexGrid1.MergeRow(0) = True
Me.MSFlexGrid1.TextMatrix(1, 0) = " "
Me.MSFlexGrid1.TextMatrix(1, 1) = " "
Me.MSFlexGrid1.TextMatrix(1, 2) = " "
Me.MSFlexGrid1.TextMatrix(1, 3) = " "
Me.MSFlexGrid1.TextMatrix(1, 4) = " "
Me.MSFlexGrid1.TextMatrix(1, 5) = " "
Me.MSFlexGrid1.TextMatrix(1, 6) = " "
Me.MSFlexGrid1.TextMatrix(1, 7) = " "
Me.MSFlexGrid1.TextMatrix(1, 8) = " "
Me.MSFlexGrid1.TextMatrix(1, 9) = " "
Me.MSFlexGrid1.TextMatrix(1, 10) = " "
Me.MSFlexGrid1.TextMatrix(1, 11) = " "
Me.MSFlexGrid1.TextMatrix(1, 12) = " "
Me.MSFlexGrid1.TextMatrix(1, 13) = " "
MSFlexGrid1.MergeCells = flexMergeFree
MSFlexGrid1.MergeRow(1) = True
Me.MSFlexGrid1.TextMatrix(2, 0) = " "
Me.MSFlexGrid1.TextMatrix(2, 1) = " "
Me.MSFlexGrid1.TextMatrix(2, 2) = " "
Me.MSFlexGrid1.TextMatrix(2, 3) = " "
Me.MSFlexGrid1.TextMatrix(2, 4) = " "
Me.MSFlexGrid1.TextMatrix(2, 5) = " "
Me.MSFlexGrid1.TextMatrix(2, 6) = " "
Me.MSFlexGrid1.TextMatrix(2, 7) = " "
Me.MSFlexGrid1.TextMatrix(2, 8) = " "
Me.MSFlexGrid1.TextMatrix(2, 9) = " "
Me.MSFlexGrid1.TextMatrix(2, 10) = " "
Me.MSFlexGrid1.TextMatrix(2, 11) = " "
Me.MSFlexGrid1.TextMatrix(2, 12) = " "
Me.MSFlexGrid1.TextMatrix(2, 13) = " "

MSFlexGrid1.MergeCells = flexMergeFree
MSFlexGrid1.MergeRow(2) = True

Me.MSFlexGrid1.TextMatrix(3, 0) = " "
Me.MSFlexGrid1.TextMatrix(3, 1) = " "
Me.MSFlexGrid1.TextMatrix(3, 2) = " Ș "
Me.MSFlexGrid1.TextMatrix(3, 3) = " "
Me.MSFlexGrid1.TextMatrix(3, 4) = " "
Me.MSFlexGrid1.TextMatrix(3, 5) = " "
Me.MSFlexGrid1.TextMatrix(3, 6) = " "
Me.MSFlexGrid1.TextMatrix(3, 7) = " "
Me.MSFlexGrid1.TextMatrix(3, 8) = " "
Me.MSFlexGrid1.TextMatrix(3, 9) = " "
Me.MSFlexGrid1.TextMatrix(3, 10) = " "
Me.MSFlexGrid1.TextMatrix(3, 11) = " "
Me.MSFlexGrid1.TextMatrix(3, 12) = " "
Me.MSFlexGrid1.TextMatrix(3, 13) = " "
Me.MSFlexGrid1.Redraw = True
End Sub

Hi everyone, i have a problem with highlighting a selected row on a msflexgrid.
i have written a method, called DoubleClick. which is entered once the msflexgrid is double clicked on. This process allows you to edit data in the grid(each row is an indiviual record).

After editing and closing the record, i wanted that particular row to stay highlighted until i selected another row; which would then in-turn become highlighted, after it was enetered/edited.

can someone please help, because i just cant get around this one.




I have a database called Test.mdb, table named titles and field named ID, I need to display the ID in a flexGrid, how can I display certain fields from database to a flexgrid???

Msflexgrid /vba

I'm reading data into a msflexgrid. The data loads
fine but when I make the useform (and flexgrid)
visible all but the last 2 columns of the flexgid
and minimized.

All the columns of data are there and I can
resize the columns by dragging but I don't get
why they don't appear "full-sized"

Am I not setting some property correctly?

Here's my code
UserForm1.MSFlexGrid1.Rows = numSites + 1
With UserForm1.MSFlexGrid1
.Row = 0
For j = 1 To 10
.Col = j
Select Case j
Case Is = 1
.ColWidth(j) = 4
.Text = "ID"
Case Is = 2
.ColWidth(j) = 25
.Text = "Domain"
Case Is = 3
.ColWidth(j) = 25
.Text = "Property"
Case Is = 4
.ColWidth(j) = 25
.Text = "Category"
Case Is = 5
.ColWidth(j) = 6
.Text = "Profile"
Case Is = 6
.Text = "Cost"
Case Is = 7
.Text = "4-wk GRPs"
Case Is = 8
.Text = "4wk Reach"
Case Is = 9
.ColWidth(j) = 10
.Text = "Time/View"
Case Is = 10
.ColWidth(j) = 20
.Text = "Total View Time"
End Select
Next j
End With

I need to know how to find when you have done a multi selection of more than one line in a msflexgrid.

Is this done under cell selection or row selection or msflexgrid change

Also need to know how to set start of the Highlited selection and stop of highlited selection.

How can i trap vbkeydown, vbkeyup, vbkeyright, vbkeyleft key stroke in
MSFlexGrid Control. The KeyDown, KeyPress events is not working with
these keys in this control. IS THERE ANY SOLUTIONS ?

MSFlexGrid Help
Text6.Text = 0
For j = FormRoster.MSFlexGrid2.Rows - 1 To 0 Step -1
Text6.Text = Val(Text6.Text) + Val(FormRoster.MSFlexGrid2.TextMatrix(FormRoster.MSFlexGrid2.Row, 10))
Next j

this is part of my code to add the data in row 10 of the msflexgrid together but it doesnt seem to work properly

for instance if there is two items in the msflexgrid and the first line in coloumn 10 it has 1000

and if the second line in column 10 it has 2000

it adds them up and gives 2000, im not sure why it does this

Hey guys,

I have a text file (about 300 lines composed by numbers separated by spaces) loaded in the first column of a MsFlexGrid. Now I need to count and display the odd and even numbers on the next columns of the grid, using 2 diferent command butons...

is it possible?

Note: The grid is already setted up (columns size, titles, alignment)


Hi, i just started using VB and need some pointers on using the flexgrid.

I notice that the only way to write something on a flexgrid is to use object.textmatrix (row,col). Is there anyway i could type something directly on the flexgrid when the program is running? It doesnt respond like how the normal textbox does.
Also, when i click on a particular cell in the flexgrid, isit possible for it to return a feedback (disclosing its row and column within the grid)? Im planning to use the keypress function to delete texts within a cell in the grid.
Pls do help me.
Thank you

following code has a button that removes the selected row from the grid. reset index, is what i am going to use so that the first column is always secquential, so all rows after the deleted one moves up one row.

Private Sub cmdDeleteMSFlexGridRows_Click()
MSFlexGrid1.RemoveItem (MSFlexGrid1.RowSel)
Call resetIndex
End Sub

Private Sub resetIndex()
vIndex = 0
Do While Not msflexgrid1.?????
MSFlexGrid1(vIndex + 1, 0) = vIndex + 1
vIndex = vIndex + 1
Next Row

End Sub
i dont know what to use at the ???? to say something similar to End Of File.
any ideas to what to put there for this to work?

is there a better way of getting row indexes? currently my code looks like this.
If Not RSp.EOF Then
MSFlexGrid1.AddItem MSFlexGrid1.Rows 'Modified BY Pyash
MSFlexGrid1.TextMatrix(vIndex + 1, 0) = vIndex + 1
MSFlexGrid1.TextMatrix(vIndex + 1, 1) = RSp!barcode
MSFlexGrid1.TextMatrix(vIndex + 1, 2) = RSp!ProductName
MSFlexGrid1.TextMatrix(vIndex + 1, 3) = Format(RSp!sellingprice, "currency")
MSFlexGrid1.TextMatrix(vIndex + 1, 4) = 1
MSFlexGrid1.TextMatrix(vIndex + 1, 5) = Format(MSFlexGrid1.TextMatrix(vIndex + 1, 3) * MSFlexGrid1.TextMatrix(vIndex + 1, 4), "Currency")
vIndex = vIndex + 1
Text1 = ""


I have two textboxes which accepts date. Also I have a command button which on clicking will display dates at an interval of every 3 months on the msflexgrid.

Here's my code

Private Sub cmdCalculateInterestDates_Click()
MSFlexGrid1.Row = 1
MSFlexGrid1.Cols = 1
Dim d1 As String
DepDate = Format(txtDepDate.Text, Format("mm/dd/yyyy"))
MatDate = Format(txtMatDate.Text, Format("mm/dd/yyyy"))
IntDate = DepDate
Do Until IntDate >= MatDate
IntDate = DateAdd("m", 3, IntDate)
d1 = Format(IntDate, "dd/mmm/yyyy")
MSFlexGrid1.AddItem d1
End Sub
The code works fine when for the first time I enter two dates .
When I enter for the second time and click on the command button the previous values get cleared(cells become blank) but the cells do not move forward.
eg. I had 4 values when I enter value for the first time Now when I enter two new values in the text box and click on the command button, the first 4 cells are blank but the 4 cells do not move forward instead the new dates start from cell 5 onwards.

What am I supposed to do to make the rows move forward. Further I want heading called as "Interest Dates" to be displayed on the header. i tried using textmatrix but could not succeed.

Kindly throw some light.


About Msflexgrid
hey guys.
when i use msflexgrid, can i change the bookmark of recordset when i set focus one certain row of record in msflexgrid? and when i use up-down button of data control, can i set focus to the corresponding record in the msflexgrid table? Thx a lot

MsFlexGrid Help
I have 2 forms frm1 and has an grd1 and frm2 with another grd2 on it.
When I double click a cell in grd1 in frm1 I display frm2 but the grd2 is not showing anything the window is not refreshed, and I have to click on the grd2 to see the cells.

I tried grd2.Redraw and grd2.Refresh but no luck.
I also tried in frm2 the Form_Resize() and the Form_Paint() and then grd2.Redraw without any luck.

This only happens if I click on the last column of grd1 in frm1.

Help please,



MsFlexGrid && VBA
Hi all,

Is it possible to add a MsFlexGrid to a user from in VBA - Excel? If it is how do you do it.

Many thanks in advance

is there a way to allow typing directly into them? it would make some things a lot easier - but i don't know of a way to do it.

i usually use inputbox's to make it quicker

How can I make my MSFlexgrid to increase the height of a row to show all the text that is in that cell. When I increrase the width the height should decrease.

Your help is most welcome.


How can I set Font size and Bold for a full row in MSFlexGrid


How to let the user to select one of the row in the MsFlexGrid and delete it?

MSFlexGrid Help PLEASE!!!
I am using the MSFlexGrid on a payroll application that I am making for my dad. My problem is this: How can I save the data I have entered into a .dat file and also load it back into the cells when the form is reopened each time? If you can give me a basic example, I can most likely figure it out from there. Any help you can give me would be much appreciated!


I've not tried to add text from one FlexGrid to another. Could someone help me with this please? This is what I have so far. This only adds more Columns on my fixed row. I want to add the Selected row from ListGrid to the next empty row on MealGrid. Thanks for any help.

Private Sub Command5_Click()

Dim intResponse As String
If ListGrid.RowSel < 1 Then
GoTo dbErrHandler
End If
If SSTabMeal.Tab = 0 Then
MealGrid(0) = ListGrid.TextMatrix(ListGrid.RowSel, ListGrid.Col + 1)
ElseIf SSTabMeal.Tab = 1 Then
MealGrid(1) = ListGrid.TextMatrix(ListGrid.Row, ListGrid.Col + 1)
ElseIf SSTabMeal.Tab = 2 Then
MealGrid(2) = ListGrid.TextMatrix(ListGrid.Row, ListGrid.Col + 1)
ElseIf SSTabMeal.Tab = 3 Then
MealGrid(3) = ListGrid.TextMatrix(ListGrid.Row, ListGrid.Col + 1)
ElseIf SSTabMeal.Tab = 4 Then
MealGrid(4) = ListGrid.TextMatrix(ListGrid.Row, ListGrid.Col + 1)
ElseIf SSTabMeal.Tab = 5 Then
MealGrid(5) = ListGrid.TextMatrix(ListGrid.Row, ListGrid.Col + 1)
End If

Exit Sub
intResponse = MsgBox("You must first choose a food item to add to the form!", 0)

End Sub

Is there a way to tell your program to auto size the cells of an MSFlexGrid. Because I think it's dumb if you have to manually change it's size if the text is to long. If there is not... is there anything like MSFlexGrid (like a database) that I can use. Thanks in advance for your time.

I'm new to MSFlexGrid and know very little about it. I'm trying to do a number of basic things:

1. Change the width of my fixed columns
2. Display data from column c, table t of data.mdb in a corresponding column of my grid
3. Merge columns

Any help on any of the above topics would be greatly appreciated. Thanks in advance!

I have searched for a similar problem.
I have a frmmain.frm with a msflexgrid on it. When I click on a row I want another frmrecords.frm(based on the same recordset) to open but at the particular record or row clicked.
This is the code:

Private Sub MSFlexGrid1_Click()
Dim f As New frmrecords
Dim k As Long
k = MSFlexGrid1.RowSel 'selects row

On Error GoTo moveErr
With frmrecords.datPrimaryRS.Recordset
.Move k 'move to row
If .EOF Then .MoveLast
End With
Exit Sub

MsgBox Err.Description

This works perfect from a button on the records form but will not from the main form. Any help would be appreciated.
Private Sub Command1_Click()

code from button on records form:
On Error GoTo moveErr
With datPrimaryRS.Recordset

.Move 5
If .EOF Then .MoveLast
End With
Exit Sub
MsgBox Err.Description

Copyright 2005-08, All rights reserved