Re: flexgrid update problem
We prefer it if you do upload the project (or at least the form as an .frm file), as it is easier to work with.
In this case tho just showing un the appropriate code (as following) would be more appropriate:
Code:
'-----------------------------------------------------------------------------
Private Sub cmdSave_Click()
'-----------------------------------------------------------------------------
Dim strPhone As String
Dim lngIDField As Long
Dim strSQL As String
If Not ValidateFormFields Then Exit Sub
strPhone = txtArea.Text & txtPrfx.Text & txtLine.Text
If mstrMaintMode = "ADD" Then
...
Else
lngIDField = CLng(grdCustomer.TextMatrix(mlngCustGridRow, 8)) >>> HERE IS THE PROBLEM
...
The error "data type mismatch" means that you are trying to convert from one data type (String) to another (Long), but the data is not valid for that - it seems that the text in cell (mlngCustGridRow, 8) cannot be converted to a number.
What I would recommend is to check the value is valid first, eg:
Code:
Else
Dim strIDField as String
strIDField = grdCustomer.TextMatrix(mlngCustGridRow, 8)
If (strIDField = "") or Not(IsNumeric(strIDField)) Then
MsgBox "Please set an ID value!"
Exit Sub
End If
lngIDField = CLng(strIDField)
...
Re: flexgrid update problem
Type mis match is usually a problem for trying to store different types into a variable or field.
Since you don't know which line it is at it is time you got to know vb6 debug bits.
First on the first line of code in cmdSave
(If Not ValidateFormFields Then Exit Sub)
Put a breakpoint (to do this left click in the margin and a circle should appear. The line should also be highlighted.
Now run your app. Click the buttons like you did, and when you get to the save bit the code should pop up and be highlighted (yellow I think was the default).
From here you use f8 to step line by line through the code. If you hover over variables they should tell you what they are (values) or you can use ctrl+g to use the immediates window.
Other alternative is to use error handling (read up on it...?)
Code:
'dim lines
on error goto errh
'your code here
exit sub
errh:
resume next
Put the break point on the resume next. If an error occurs this grabs it, the resume next moves to the next line of code after the error. You can then go back up one to find out where the error is....
Post up if you get it more pinpointed.
1 Attachment(s)
Re: flexgrid update problem
si_the_geek, i have attached the project so that way you will see the data i'm trying to save/update. I have try with you suggestions but didn't worked at least in my end.
I appreciate the help of both. Thanks.
2005
Re: flexgrid update problem
What resolution are you developing in?
I can't even see the buttons.
Re: flexgrid update problem
ohh, i'm sorry i'm currently using 1920 by 1200, but 1280 by 1024 should work also. That was another question i was planning to do later, what resolution is the best for programming purposes for an app to be used on different computers. let me know if you need me to mod the UI for you to look at.
Re: flexgrid update problem
Ok, I ran it in 1280 by 1024 and I still saw no buttons (although I see the code for each button in the code window.)
Re: flexgrid update problem
should i move the buttons real quick and re-attach the project so you can run the app?
Re: flexgrid update problem
Type Mismatch errors are pretty common and generally speaking, pretty easy to fix, but in order to do so I would like to run your save routine, so at least that button should visible.
On a completely unrelated note, who is going to be using this app? Will all your potential customers have this resolution problem or is this an internal application and all of the PCs in your company are running the same way?
Re: flexgrid update problem
Hack, i have re-attached the project in post number 4, now you should be able to see all the app at 1280 by 1024.
Almost all pc's that will be using the app are running at 1280x1024, but that's something i will work cuz not 100% will be able to run it. At what resolution did you develop your app's?
Let me know, thanks...
Re: flexgrid update problem
Re: flexgrid update problem
You should generally develop apps in the lowest resolution that could possibly be used, and always allow your form(s) to work at any resolution/window size that the user has set - by moving/resizing controls appropriately. An explanation of how to do this can be seen in the "Forms" section of our Classic VB FAQs (link in my signature).
Your Zip file is missing several files (.frm and .bas files), so it doesn't run at the moment.. and I'm not sure that I have the time to look at it properly myself.
Re: flexgrid update problem
You are blowing up on this line
Code:
lngIDField = CLng(grdProject.TextMatrix(mlngProjGridRow, 33))
The first time through, it doesn't hit this line. The next time it does.
TextMatrix is looking for text (I think.....I've not done much work with Flexgrids) and mlngProjGridRow is a number hence the Type Mismatch.
Now, excuse me while I put my screen back to normal. :D
Re: flexgrid update problem
Your analysis is spot on.. similar to what I spotted in post #2.
I'm not sure why the value in that column is not valid (presumably it is filled from somewhere else, but not being done 'properly' - which needs to be corrected), but the validation should be the same.
Re: flexgrid update problem
Post number 4 now should have all the nessesary files, sorry about that. Have many ppl here talking and talking. I think the only one working is me...
What i don't understand is if i close the app and then re-open it, i can update any file in it without errors. Every time i hit update i should be hitting this code:
lngIDField = CLng(grdProject.TextMatrix(mlngProjGridRow, 33))
And why it gives error only if i add, save and then update?
Thanks to both!
Re: flexgrid update problem
Put a break in the code and step through it to see what it is actually doing.