need help in vb 6 programming

krishnandu.sarkar

Simply a DIGITian
Staff member
Ok, then there is another possibility which can say COUNT field incorrect is, the SQL query that you are building.

But the basic rule remains same. Try to learn debugging by the message you are getting. COUNT Field Incorrect means the No of Fields you are passing, the basic problem lies there.

Anyway, I think it's problem with the SQL Query. May be some field contains ' character and that's what creating the problem but ending the quote for the SQL String.

If you have any ' in any of the text field try Sanitizing it, you can try Replace method to do that. Replace ' with '' (Note that it's 2 single ' char not the " double one).

Anyway, in programming terms it's called escape sequence.

BTW your code may only be fine for Insert, for Update and all you need to use Adodc1.Recordset.Edit AFAIK.
 
OP
R

rabjabber

Journeyman
i don't entirely get what you are trying to say but i know that there is no ' in any of the field names or records or anywhere

can some thing else cause this problem

i'm trying the hit and try method
i omit a piece and then see if it works

so far i know 6 fields that are not causing the problem
 

krishnandu.sarkar

Simply a DIGITian
Staff member
Well without checking the program and database design it's hard to figure out. Did you tried googling for the same error?
 
OP
R

rabjabber

Journeyman
don't worry, solved

now that leaves me with two more problems. i use the following code to keepa check that the data entered is numeric

Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii > 47 And KeyAscii < 58) Or (KeyAscii = 127 Or KeyAscii = 8)) Then MsgBox "please enter valid characters"
End Sub


it works just fine but after displaying the msgbox, it still enters the value


the second problem :-

there are 4 radiobuttons on one form 2 for gender and 2 for some other **** that i forgot (maybe marital status) but while the program is running, i can only select one of them. can you tell me the code to be able to select two of them (1 for each)

and also how to get the input from those radio buttons to the database

thnx.....
 

krishnandu.sarkar

Simply a DIGITian
Staff member
don't worry, solved

Care to share what was the problem and how you solved it? It's just for incase anyone looking for the same problem will get the answer

now that leaves me with two more problems. i use the following code to keepa check that the data entered is numeric

Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii > 47 And KeyAscii < 58) Or (KeyAscii = 127 Or KeyAscii = 8)) Then MsgBox "please enter valid characters"
End Sub

it works just fine but after displaying the msgbox, it still enters the value

LOL..!! I used to code in VB6 around 3 years ago. I guess, Keypress event passes something like KeyPressEvent Object or something like that

So it'll be much like e.KeyCode > 47 and so on... And to actually stop that e.Keypress = false.

But I'm not sure whether this exists in VB6.

If not, you can use it as function like if KeyAscii is within your range return true else return false and based on that clear the Textbox by Textbox.Text = "" (i.e. making it blank)

the second problem :-

there are 4 radiobuttons on one form 2 for gender and 2 for some other **** that i forgot (maybe marital status) but while the program is running, i can only select one of them. can you tell me the code to be able to select two of them (1 for each)

and also how to get the input from those radio buttons to the database

thnx.....

Yeah by default, all the Radio Buttons in a form is treated as single group. You can set Group Properties in Radio Buttons, that will do. Otherwise you can use Panel and then place Radio Buttons to that panel to group them.

Mean insert a panel from toolbox and place Male / Female Radio Buttons on that and insert another panel and place Married / Unmarried radio buttons on that.

Otherwise check if Group Property is there (It's there in VB.NET I guess, not sure about VB6), if it's present them set Gender as group to Male / Female RB and Martial_Status on Married / Unmarried RB
 
OP
R

rabjabber

Journeyman
Care to share what was the problem and how you solved it? It's just for incase anyone looking for the same problem will get the answer

idk how i solved it
i just deleted all my databases made them again with simpler field names and all data types set to text and then re inserted the code



LOL..!! I used to code in VB6 around 3 years ago. I guess, Keypress event passes something like KeyPressEvent Object or something like that

So it'll be much like e.KeyCode > 47 and so on... And to actually stop that e.Keypress = false.

But I'm not sure whether this exists in VB6.

If not, you can use it as function like if KeyAscii is within your range return true else return false and based on that clear the Textbox by Textbox.Text = "" (i.e. making it blank)

do u mean that i should declare a variable and then make it true if my IF......THEN condition is satisfied and if the variable is true then clear the textbox?



Yeah by default, all the Radio Buttons in a form is treated as single group. You can set Group Properties in Radio Buttons, that will do. Otherwise you can use Panel and then place Radio Buttons to that panel to group them.

Mean insert a panel from toolbox and place Male / Female Radio Buttons on that and insert another panel and place Married / Unmarried radio buttons on that.

Otherwise check if Group Property is there (It's there in VB.NET I guess, not sure about VB6), if it's present them set Gender as group to Male / Female RB and Martial_Status on Married / Unmarried RB

thnx............. i'll check and let u know
 

krishnandu.sarkar

Simply a DIGITian
Staff member
idk how i solved it
i just deleted all my databases made them again with simpler field names and all data types set to text and then re inserted the code

Got it, it was problem with the Field Names. Don't use space in field names as I said above in the beginning, it was creating problem while building the query (which takes place in the background).

do u mean that i should declare a variable and then make it true if my IF......THEN condition is satisfied and if the variable is true then clear the textbox?

Yeah, I meant that.

But you don't need to, as I was much accustomed with VB.NET now, I forgot in VB6 the it used to be KeyAscii = 0. This makes setting the KeyPress ASCII to be 0 and insert nothing.

So,

Code:
Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii > 47 And KeyAscii < 58) Or (KeyAscii = 127 Or KeyAscii = 8)) Then 
    MsgBox "please enter valid characters"
    KeyAscii = 0 'Prevents Input
End Sub

thnx............. i'll check and let u know

Sure :)
 
OP
R

rabjabber

Journeyman
But you don't need to, as I was much accustomed with VB.NET now, I forgot in VB6 the it used to be KeyAscii = 0. This makes setting the KeyPress ASCII to be 0 and insert nothing.

So,

Code:
Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii > 47 And KeyAscii < 58) Or (KeyAscii = 127 Or KeyAscii = 8)) Then 
    MsgBox "please enter valid characters"
    KeyAscii = 0 'Prevents Input
End Sub
thanx worked like a charm:):):):)

by panel do u mean frame??
coz that didn't work
i don't even know what frames are for
 
OP
R

rabjabber

Journeyman
one more thing..........

if i want to store a copy of the entire project in, say a pen drive, do i 'save forms as' and then the project in another folder and then copy it to the pen drive or is there an easier method
 
Top Bottom