aplimedia
asked on
varible column to update in an access database using dao
I would like to do next:
In a vb6 form I have 1 textbox, 2 listboxex, and one button
In list6 I have the columns of the table , I will use it to select the name of the column of the access database I want to change
In list66 I have the type of column of list6 values.
In textbox2 I will enter the value for the column I have choosen
I am using dao
When I click in the button I would like the program check if the textbox2.text is correct for the field selected.
If it is not correct, I will show a message "Sorry this value is not correct..."
If it is correct, I will update the record
my code is next:
query$ = "select * from clients"
Set ds5 = db.OpenRecordset(query$, dbOpenDynaset)
If ds5.RecordCount <> 0 Then
ds5.Movefirst
If Not IsDate(textbox2) And List66.List(list6.listinde x) = "dbDate" Then valor = "Error"
If Not IsNumeric(textbox2) And List66.List(list6.listinde x) = "dbByte" Then valor = "Error"
If Not IsNumeric(textbox2) And List66.List(list6.listinde x) = "dbInteger" Then valor = "Error"
If Not IsNumeric(textbox2) And List66.List(list6.listinde x) = "dbByte" Then valor = "Error"
If Not IsNumeric(textbox2) And List66.List(list6.listinde x) = "dbLong" Then valor = "Error"
If Not IsNumeric(textbox2) And List66.List(list6.listinde x) = "dbCurrency" Then valor = "Error"
If Not IsNumeric(textbox2) And List66.List(list6.listinde x) = "dbSingle" Then valor = "Error"
If Not IsNumeric(textbox2) And List66.List(list6.listinde x) = "dbDouble" Then valor = "Error"
If Not IsNumeric(textbox2) And List66.List(list6.listinde x) = "dbLongBinary" Then valor = "Error"
if valor ="Error" then
msgbox "Error"
else
ds5.edit
ds5!...... = textbox2 *here is the problem, because the name of the field to update is in list6
ds5.update
ds5.close
Any help? Thank you very much.
In a vb6 form I have 1 textbox, 2 listboxex, and one button
In list6 I have the columns of the table , I will use it to select the name of the column of the access database I want to change
In list66 I have the type of column of list6 values.
In textbox2 I will enter the value for the column I have choosen
I am using dao
When I click in the button I would like the program check if the textbox2.text is correct for the field selected.
If it is not correct, I will show a message "Sorry this value is not correct..."
If it is correct, I will update the record
my code is next:
query$ = "select * from clients"
Set ds5 = db.OpenRecordset(query$, dbOpenDynaset)
If ds5.RecordCount <> 0 Then
ds5.Movefirst
If Not IsDate(textbox2) And List66.List(list6.listinde
If Not IsNumeric(textbox2) And List66.List(list6.listinde
If Not IsNumeric(textbox2) And List66.List(list6.listinde
If Not IsNumeric(textbox2) And List66.List(list6.listinde
If Not IsNumeric(textbox2) And List66.List(list6.listinde
If Not IsNumeric(textbox2) And List66.List(list6.listinde
If Not IsNumeric(textbox2) And List66.List(list6.listinde
If Not IsNumeric(textbox2) And List66.List(list6.listinde
If Not IsNumeric(textbox2) And List66.List(list6.listinde
if valor ="Error" then
msgbox "Error"
else
ds5.edit
ds5!...... = textbox2 *here is the problem, because the name of the field to update is in list6
ds5.update
ds5.close
Any help? Thank you very much.
Can you state what happens (or does not happen) when you run your code?
Is that your entire code?
Not sure if, or where you are declaring your variables...
query$
ds5
valor
Not sure if, or where you are declaring your variables...
query$
ds5
valor
I may be misunderstanding something here...
What's the need for the recordset?
From your question, it seems like you are validating one value...?
What's the need for the recordset?
From your question, it seems like you are validating one value...?
It would be much easier to just try and perform the update and catch the error which will be "Data type mismatch".
If so, pop the messagebox with a human readable error message.
/gustav
If so, pop the messagebox with a human readable error message.
/gustav
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I've requested that this question be closed as follows:
Accepted answer: 250 points for Jeffrey Coachman's comment #a40592361
Assisted answer: 250 points for Gustav Brock's comment #a40592295
for the following reason:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Accepted answer: 250 points for Jeffrey Coachman's comment #a40592361
Assisted answer: 250 points for Gustav Brock's comment #a40592295
for the following reason:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.