PDA

View Full Version : Solved: I need to debug, Can you help pls?



maryam
01-29-2007, 01:28 AM
I have this code for sending the data of a DataGrid to Sheet 3.
It is one row less in sheet3.
when I try to remove -1 from RecordCount-1 it gives debug. Can you help me? mI=0 just gives the title (name of the two columns) so we sholud have the same number of row in sheet3 as the number of rows in DataGrid that is Recordcount, but I dont know why it gives debug.

Private Sub UserForm_Terminate()
Dim mI As Long, k As Long
r.UpdateBatch
r.MoveFirst
For mI = 0 To r.RecordCount - 1
If mI = 0 Then
Worksheets("Sheet3").Cells(mI + 1, 1).Value = r.Fields(mI).Name
Worksheets("Sheet3").Cells(mI + 1, 2).Value = r.Fields(mI + 1).Name
Else
Worksheets("Sheet3").Cells(mI + 1, 1).Value = r.Fields(0).Value
Worksheets("Sheet3").Cells(mI + 1, 2).Value = r.Fields(1).Value
End If
If Not r.BOF Or Not r.EOF Then r.MoveNext
Next
Set r = Nothing
End Sub

JimmyTheHand
01-29-2007, 03:48 AM
The first record (mI=0) was missing, because the field names were displayed instead, and only the field names.


Private Sub UserForm_Terminate()
Dim mI As Long, k As Long
r.UpdateBatch
r.MoveFirst
For mI = 0 To r.RecordCount - 1
If mI = 0 Then
Worksheets("Sheet3").Cells(mI + 1, 1).Value = r.Fields(mI).Name
Worksheets("Sheet3").Cells(mI + 1, 2).Value = r.Fields(mI + 1).Name
End If
Worksheets("Sheet3").Cells(mI + 2, 1).Value = r.Fields(0).Value
Worksheets("Sheet3").Cells(mI + 2, 2).Value = r.Fields(1).Value

If Not r.BOF Or Not r.EOF Then r.MoveNext
Next
Set r = Nothing
End Sub

Cheers

Jimmy

maryam
01-29-2007, 03:54 AM
Dear Jimmy,
Thank you very much. I have a post about "Assign macros to the control of toolbar" Can't you help with that? I need it, but no new reply today.
How can I see who is online?



many thanks,
Maryam

JimmyTheHand
01-29-2007, 04:13 AM
A list of logged in people is available at the bottom of VBAX main page.
A list of those people who are viewing Excel page is at the bottom of Excel Page.
Also, if you want to know of a particular member, you can view their profile, or that small green circle beneath their names in any post. If the circle is bright green, then they are online. If it's dark, they are not.
I'll have a look at the other thread of yours.

Bob Phillips
01-29-2007, 04:16 AM
It is at the foot of the forum (http://vbaexpress.com/forum/) page, or (Excel viewing) the foot of the Excel (http://vbaexpress.com/forum/=SUM%28--%28FREQUENCY%28IF%28A1:A20=E1,MATCH%28B1:B20,B1:B20,0%29%29,ROW%28INDIRECT% 28%221:%22&ROWS%28B1:B20%29%29%29%29%3E0%29%29) page.

maryam
01-29-2007, 04:35 AM
Dear Xld, thank you. How can i send my file to you if you can help me with another post which is "Assign macros to the controls of a toolbar. My email is maryamunique@yahoo.com

maryam
01-29-2007, 04:36 AM
Dear Xld, thank you. How can i send my file to you if you can help me with another post which is "Assign macros to the controls of a toolbar. My email is maryamunique@yahoo.com

maryam
01-29-2007, 04:38 AM
Dear Administrator,
Can I close my post myself or it is done by the site owners. This post is finished thanks to Jimmy.

Bob Phillips
01-29-2007, 04:42 AM
Go to the Thread Tools menu at the head of the thread, and there is an option to Mark itr Solved there.

Bob Phillips
01-29-2007, 04:44 AM
Dear Xld, thank you. How can i send my file to you if you can help me with another post which is "Assign macros to the controls of a toolbar. My email is maryamunique@yahoo.com

Before we go there, I am struggling to understand what the problem is, and you don't seem to answer questions asked of you. Most importantly at the moment, are the macros that you are trying to link to in the same workbook as the toolbars? And why have you not tried our suggestion of building the menus dynamically?

maryam
01-29-2007, 04:50 AM
hi. thank you for your concern and sorry if I am not a good student. I have two toolbar one of them is made with tools/ customize and the other one ( which I named it the back up) is made by writting codes in a module6. The macros (sub menus) I assign to the controls of the toolbar are written in private subs in another module(module6). The problem is that when I write this formula Software.xls!Addstream for example the control works but when I close Software and open again the macros cannot be found nad it sais F:\......\Software.xls!Addstream cannot be found. If I remove the path control works again but I have to revise the formula each time I open!

maryam
01-29-2007, 04:51 AM
even for the toolbar that I made in module 6, the same problem exists and the path is added to the macro name, so when I click on the controls the macro cannot be found.

maryam
01-29-2007, 04:53 AM
I found this on internet :
http://exceltips.vitalnews.com/Pages/T0732_Macros_in_Template_Files.html (http://exceltips.vitalnews.com/Pages/T0732_Macros_in_Template_Files.html).
I think this is a good description of the same problme I am encountering, I followed the description for solving the problem but cannot fix it I meanI change the macro formula and save my file, will have the problme when open it again.

lucas
01-29-2007, 08:14 AM
Most importantly at the moment, are the macros that you are trying to link to in the same workbook as the toolbars? And why have you not tried our suggestion of building the menus dynamically?

Hi Mary....could you please answer the two questions that Bob has put forward?

1. are the macro's in the same workbook as the toolbars.(if your using a template to do this it does change things a little so it would be beneficial for us to know).

2. If they are in the same workbook why are you using customize instead of considering the dynamic creation of the toolbars as possibly a better approach and .............possibly a solution to the problem?

Experts here are offering good advice and asking fair questions to which you are not responding to very well. If there is a language problem please let us know. Otherwise you risk people abandoning trying to help you with your problem. Good help is available here but you must interact with the best answers to questions that you can provide. Please stop putting more information forward in a different direction and try to answer the questions directly until we understand. Most important.....be patient. This is not an easy medium for exchange when there are so many different skill levels involved.