|
-
May 19th, 2003, 04:44 PM
#1
Thread Starter
Addicted Member
Please read this everyone. (Especially you, Martin Liss)
Hi,
I think I am a very confused programmer because I can't find what's wrong here. Here's my code:
VB Code:
With RsDependents
Dim i As Byte
If .RecordCount > 0 Then
.MoveLast
While .BOF = False
If .Fields("EmpCode") = RsPersonalData.Fields("EmpCode") Then
.Delete
End If
.MovePrevious
Wend
.Update
End If
.Close
.Open
For i = 1 To mfgDependents.Rows - 1
.AddNew
.Fields("EmpCode") = RsPersonalData.Fields("EmpCode")
.Fields("Name") = StrConv(mfgDependents.TextMatrix(i, 1), vbProperCase)
.Fields("Age") = Val(mfgDependents.TextMatrix(i, 2))
.Fields("Relationship") = StrConv(mfgDependents.TextMatrix(i, 3), vbProperCase)
.Fields("Address") = StrConv(mfgDependents.TextMatrix(i, 4), vbProperCase)
.Update
Next i
End With
It's supposed to delete the contents of a table who's empcode is the same as the empcode on another table, and afterwards add the entire contents of a flexgrid to it. Heres the problem;
everytime this code runs, i get an error message "Error occured" and then vb highlights the line next to .Addnew. Can anyone help me here?
Also, does anyone know how i can add a new page to a word document using vb and afterwards, edit certain portions of it?
[vbcode]
If SymptomsPersist Then Goto VBForum
[/vbcode]
This is our world now...the world of the electron and the switch, the beauty of the baud.We make use of a service already existing without paying for what could be dirt cheep if it wasn't run by profiteering gluttons, and you call us criminals. We explore...and you call us criminals. We exist without skin color, without nationality, without religious bias...and you call us criminals. You build atomic bombs, wage wars, murder, cheat, and lie to us and try to make us believe it is for our own good, yet we're the criminals. Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for. I am a hacker and this is my manifesto.You may stop this individual, but you can't stop us all...after all, we're all alike."
+++The Mentor+++
-
May 19th, 2003, 04:49 PM
#2
When you say "new page" do you mean a new blank page (in other words you just want to add a page break) or do you want to append an existing word doc which consists of just one page?
-
May 19th, 2003, 04:51 PM
#3
PowerPoster
Well
1st question : Does your code delete the items in the database?
2nd question : You seem to update regardless of whether the record is deleted ot not. Did you mean for that to be there?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
May 19th, 2003, 05:07 PM
#4
Thread Starter
Addicted Member
I really am confused
I meant to delete the records in a table in my database, and this code does just that. What's bugging me is that i always get that error message i said earlier. And another thing, when i moved the mouse over the code after the .addnew, it showed a tooltip that .fields("Empcode") = null.
And about the word thing. I am trying to make word generate my reports in my application ( I don't like to use datareport). So i do not know how many pages my report will have. If i will only create one page and then replace certain text's with information from my database and afterwards save it to another filename, then i will surely need to add more pages with the same contents as the original document.
[vbcode]
If SymptomsPersist Then Goto VBForum
[/vbcode]
This is our world now...the world of the electron and the switch, the beauty of the baud.We make use of a service already existing without paying for what could be dirt cheep if it wasn't run by profiteering gluttons, and you call us criminals. We explore...and you call us criminals. We exist without skin color, without nationality, without religious bias...and you call us criminals. You build atomic bombs, wage wars, murder, cheat, and lie to us and try to make us believe it is for our own good, yet we're the criminals. Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for. I am a hacker and this is my manifesto.You may stop this individual, but you can't stop us all...after all, we're all alike."
+++The Mentor+++
-
May 19th, 2003, 06:22 PM
#5
Fanatic Member
Re: I really am confused
Originally posted by ripple214
I meant to delete the records in a table in my database, and this code does just that. What's bugging me is that i always get that error message i said earlier. And another thing, when i moved the mouse over the code after the .addnew, it showed a tooltip that .fields("Empcode") = null.
"Error occured" is not exactly a runtime error message... is this everything that you get? when your code stops, write
in your immediate window and tell us what you get. the fact that .fields("Empcode") is null, even after an .AddNew operation, is not an error - this is how it is supposed to be in that context.
there are 2 reasons why i leave my work unfinished:
(1) i'm getting old.
-
Jun 5th, 2003, 01:47 PM
#6
New Member
check if the value is null and assign empty string if it is null.
Last edited by NewComer; Jun 5th, 2003 at 02:07 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|