about field update using function with case - ms-access

I'm trying to update some field value depending two string field using a function with If and Case, function below:
Private Function checkDATI(tipotransazione As String, tipovendita As String) As String
Dim r As String
r = ""
If tipotransazione = "VENDITA" Then
Select Case tipovendita
Case "ARMI"
If Me.txtMatricola = "" Then r = "Matricola"
If Me.txtModello = "" Then r = "Modello"
If Me.txtCalibro = "" Then r = "Calibro"
If Me.txtTipoArma = "" Then r = "Tipo Arma"
If Me.txtFabrica = "" Then r = "Fabbrica"
Case "VENDITA ARMI/MUNIZIONI"
Case "MUNIZIONI"
End Select
End If
If tipotransazione = "ACQUISTO" Then
Select Case tipovendita
Case "ARMI"
If Me.txtMatricola = "" Then r = "Matricola"
If Me.txtModello = "" Then r = "Modello"
If Me.txtCalibro = "" Then r = "Calibro"
If Me.txtTipoArma = "" Then r = "Tipo Arma"
If Me.txtFabrica = "" Then r = "Fabbrica"
Case "VENDITA ARMI/MUNIZIONI"
Case "MUNIZIONI"
End Select
End If
checkDATI = r
End Function
And then when I call this function in a command button event as:
MsgBox (checkDATI(Me.CausaleMov, Me.txt_tipomov))
It's not updating that field. What is wrong?

When you say:
If Me.txtMatricola = "" Then r = "Matricola"
What you are doing is assigning the value: "Matricola" to the variable:r. Instead what I think you want is this:
If Me.txtMatricola = "" Then Me.txtMatricola = "Matricola"
This actually sets the value of the field: txtMatricola to "Matricola". This goes for all of the fields that are in your Case statements.

Related

Best way to convert a VBA script to google Apps script on google sheets

i'm working on a script that allows me to connect to an external API and use urlfetchapp to fetchdata, but for some objects, i have to create a dictionary of object to display the right value at the right cell, since i'm a beginner, i didn't succeed to convert this part of the script to a google apps script code, any help would be welcome :
Set TableauTaxesInclusion = New Dictionary
'Récupération des infos de taxe incluses ou pas
If Not IsEmpty(Produit("lecTaxInclusionInformationList")) Then
For t = 1 To Produit("lecTaxInclusionInformationList").Count 'Parcours des taxes incluses
Set UneTaxe = Produit("lecTaxInclusionInformationList").Item(t)
If Not IsEmpty(UneTaxe("lecTaxCode")) And Not IsNull(UneTaxe("lecTaxCode")) Then
TableauTaxesInclusion.Add UneTaxe("lecTaxCode")("code"), IIf(Not IsEmpty(UneTaxe("lecIsTaxIncludedInPrice")) And Not IsNull(UneTaxe("lecIsTaxIncludedInPrice")) And UneTaxe("lecIsTaxIncludedInPrice") = True, "X", "")
'Debug.Print UneTaxe("lecTaxCode")("code")
End If
Next
End If
If Not IsEmpty(Produit("dutyFeeTaxInformationList")) Then
Set TableauTaxes = New Dictionary
For t = 1 To Produit("dutyFeeTaxInformationList").Count
Set Taxe = Produit("dutyFeeTaxInformationList")(t)
If Not (IsNull(Taxe("dutyFeeTaxTypeCode"))) Then
If TableauTaxes.Exists(Taxe("dutyFeeTaxTypeCode")("code")) Then
TableauTaxes(Taxe("dutyFeeTaxTypeCode")("code")) = 1 + TableauTaxes(Taxe("dutyFeeTaxTypeCode")("code"))
Else
TableauTaxes.Add Taxe("dutyFeeTaxTypeCode")("code"), 1
End If
End If
Next
For t = 1 To Produit("dutyFeeTaxInformationList").Count 'Parcours des taxes
Set Taxe = Produit("dutyFeeTaxInformationList")(t)
If Not (IsNull(Taxe("dutyFeeTaxTypeCode"))) Then
If Left(Taxe("dutyFeeTaxTypeCode")("label"), 3) = "TVA" Or Left(Taxe("dutyFeeTaxTypeCode")("label"), 3) = "VAT" Then
If tva = True Then
TableauProduits(ligne, numColCheckTVA) = "X"
If TableauProduits(ligne, numColTVA) = Taxe("dutyFeeTaxTypeCode")("label") Then
If TableauProduits(ligne, numColValTVA) = "" Then
If (Taxe("dutyFeeTaxList").Count > 0) Then
TableauProduits(ligne, numColValTVA) = Taxe("dutyFeeTaxList")(1)("dutyFeeTaxRateNumber")
End If
End If
Else
TableauProduits(ligne, numColCheckTVA) = "PB"
End If
Else
TableauProduits(ligne, numColTVA) = Taxe("dutyFeeTaxTypeCode")("label")
If (Taxe("dutyFeeTaxList").Count > 0) Then
TableauProduits(ligne, numColValTVA) = Taxe("dutyFeeTaxList")(1)("dutyFeeTaxRateNumber")
If (Taxe("dutyFeeTaxList").Count > 1) Then
TableauProduits(ligne, numColCheckTVA) = "PB"
End If
End If
End If
tva = True
actually i'm just able to write the first part :
var tableautaxinclusion = [];
if (produit.leclercTaxInclusionInformationList != 0){
for(inc = 1 ; inc < produit.leclercTaxInclusionInformationList.length ; inc++ )
set Taxinc = produit.leclercTaxInclusionInformationList[inc]
}
if (Taxinc.leclercTaxCode != null & Taxinc.leclercTaxCode != 0 ){
tableataxinclusion = Taxinc
}

VBA nested if inquiry

I am trying to write write a nested if statement in VBA. In cobol, I would typically use the evaluate clause. But what do I use in VBA so as to avoid a long loop.
Example.
if cmbfield = "green" then
me.frame1.enable = true
else
me.frame2.enable = false
me.frame3.enable = false
end if
if cmbfield = "red" then
me.frame2.enable = true
else
me.frame1.enable = false
me.frame3.enable = false
end if
if cmbfield = "white" then
me.frame3.enable = true
else
me.frame1.enable = false
me.frame2.enable = false
end if
In the example you gave I'd use a switch command:
http://www.techonthenet.com/excel/formulas/case.php
Select Case test_expression
Case condition_1
result_1
Case condition_2
result_2
...
Case condition_n
result_n
Case Else
result_else
End Select
You could also do if ... elseif ... end if
http://www.techonthenet.com/excel/formulas/if_then.php
If condition_1 Then
result_1
ElseIf condition_2 Then
result_2
...
ElseIf condition_n Then
result_n
Else
result_else
End If
I do it this way:
Me.frame1.enabled = (cmbfield = "green")
Me.frame2.enabled = (cmbfield = "red")
Me.frame3.enabled = (cmbfield = "white")
Dim isGreen as Boolean, isRed as Boolean, isWhite as Boolean
isGreen = (cmbfield = "green")
isRed = (cmbfield = "red")
isWhite = (cmbfield = "white")
me.frame1.enabled = isGreen
me.frame2.enabled = isRed
me.frame3.enabled = isWhite
This is a shorter way to write the same code. Should work modulo syntax; hope this helps.

Update and insert MySQL using Classic ASP

I'm trying to update on a database in MySQL using Classic ASP, but it's not working. Could someone tell me what might be wrong in my code?
IDCliSession = Session("usuarioident")
if IDCliSession <> "" then
IDCliSession = IDCliSession
else
IDCliSession = 0
end if
set cli = conexao.execute("SELECT * FROM clientes WHERE id_cliente = "& IDCliSession &"")
senha_S = request.form("senha")
senha_C = request.form("confsenha")
senha = request.form("confsenha")
if senha1 & "" <> "" or senha2 & "" <> "" then
if senha_S <> senha_C then
response.redirect "Registro.asp?msg=A Senha e a Confirmação de Senha não são iguais. Por favor, preencha novamente!"
end if
end if
loja = "1062"
tipoPe = request.Form("tipo")
email = request.Form("email")
fone1 = request.Form("fonefixo")
fone2 = request.Form("fonecel")
cep = request.Form("cep")
tipo_residencia = request.Form("tipo_residencia")
endereco = request.Form("endereco")
numero = request.Form("numero")
bairro = request.Form("bairro")
complemento = request.Form("complemento")
cidade = request.Form("cidade")
fk_estado = request.Form("estado")
fk_pais = request.Form("pais")
data = Date()
if request.Form("newsletter") = "1" then
newsletter = 1
else
newsletter = 0
end if
conhecimento = request.Form("tipo")
modalidade = request.Form("modalidade")
modalidade_ativa = "0"
comentarios = ""
if not cli.eof then
query = "SELECT * FROM clientes WHERE email='"& Session("mail") &"'"
Set rsCliente = Server.CreateObject("ADODB.RecordSet")
rsCliente.Open query, conexao, 2, 3
rsCliente("tipo") = tipoPe
rsCliente("email") = email
rsCliente("senha") = senha
rsCliente("fone1") = fone1
rsCliente("fone2") = fone2
rsCliente("cep") = cep
rsCliente("tipo_residencia") = tipo_residencia
rsCliente("endereco") =endereco
rsCliente("numero") = numero
rsCliente("fk_pais") = fk_pais
rsCliente("newsletter") = newsletter
rsCliente("conhecimento") = conhecimento
rsCliente("modalidade") = modalidade
rsCliente.Update
rsCliente.Close
Set rsCliente = Nothing
end if
Besides inefficiency of the method you chooses, could you also look if the variables you attempt to update to actually not conflicting with database indexes or primary/foreign keys in database?
If you attempt to pass empty string into fields which set as not null it will abort procedure.
For example field tipoPe = request.Form("tipo") or email = request.Form("email") could be a mandatory in your table or set as unique. I do not see any validation for that...
Best solution would be use of a store procedure which would return you a string in case of failure or successes.
And also what are you attempt to validate her:
senha_S = request.form("senha")
senha_C = request.form("confsenha")
senha = request.form("confsenha")
if **senha1** & "" <> "" or **senha2** & "" <> "" then
if senha_S <> senha_C then
where does senha1 and senha2 comes from?
For password verification following would be more then sufficient:
if senha_S <> senha_C and len(senha_S)<8 then
using len(senha_S)<8 you also enforcing minimal lenght of the password.
Also I would recommend following changes in your redirect:
response.redirect "Registro.asp?msg='A Senha e a Confirmação de Senha não são iguais. Por favor, preencha novamente!'"
otherwise you may on your redirect page get only small portion of your message, like only first letter A.

Mysql Error - Update Query

do you find any issue in these below MySQL query. Actually this Insert query is not working. the tools picks the values from FORM controls correctly but it is not updating.
the values ain't update in MySQL DB. the coding brings the form values correctly but it is not updating in MySQL DB
actually the query where i am using in VB.Net (VS2010)
Private Sub btnupdate_Click(sender As System.Object, e As System.EventArgs) Handles btnupdate.Click
Dim ch_date As Date = dtpdate.Value
If ch_date = getToday(Now) Then
checkdate(ch_date)
Else
checkdate(ch_date)
End If
cleanfields()
End Sub
Function checkdate(ByVal chdate As Date)
Dim tmpreader As MySqlDataReader
Dim usr As String
'Dim dtp_date As Date = dtpdate.Value
usr = getUserName()
usr = getFullName(getUserName())
Try
If main_form.mySQLconn1.State = ConnectionState.Closed Then
main_form.mySQLconn1.Open()
End If
main_form.cmdproductivity.CommandText = "SELECT * FROM productivity WHERE productivity_date = #productivity_date"
main_form.cmdproductivity.Parameters("#productivity_date").Value = chdate
tmpreader = main_form.cmdproductivity.ExecuteReader()
If tmpreader.HasRows Then
main_form.cmdproductivity.CommandText = "UPDATE productivity SET agent = #agent, productivity_date = #productivity_date, actual_date = #actual_date, total_count = #total_count, eq_pr = #eq_pr, c_rebook=#c_rebook, c_nonwatson=#c_nonwatson, c_coa=#c_coa, c_watson=#c_watson, c_velocity=#c_velocity, c_quote=#c_quote, c_crd=#c_crd, c_eclaims=#c_eclaims, c_ecalls=#c_ecalls, c_xi=#c_xi, c_brazil=#c_brazil, c_cancel=#c_cancel, c_queries=#c_queries, c_partrebook=#c_partrebook, c_nci=#c_nci, c_phil=#c_phil, c_qc=#c_qc, c_watsonqc=#c_watsonqc, c_monitor=#c_monitor, c_enduser=#c_enduser, c_idoc=#c_idoc, c_servercancel=#c_servercancel, eq_rebook=#eq_rebook, eq_nonwatson=#eq_nonwatson, eq_coa=#eq_coa, eq_watson=#eq_watson, eq_velocity=#eq_velocity, eq_quote=#eq_quote, eq_crd=#eq_crd, eq_eclaims=#eq_eclaims, eq_ecalls=#eq_ecalls, eq_xi=#eq_xi, eq_brazil=#eq_brazil, eq_cancel=#eq_cancel, eq_queries=#eq_queries, eq_partrebook=#eq_partrebook, eq_nci=#eq_nci, eq_phil=#eq_phil, eq_qc=#eq_qc, eq_watsonqc=#eq_watsonqc, eq_monitor=#eq_monitor, eq_enduser=#eq_enduser, eq_idoc=#eq_idoc, eq_servercancel=#eq_servercancel WHERE productivity_date = #productivity_date"
main_form.cmdproductivity.Parameters("#agent").Value = Trim(usr)
main_form.cmdproductivity.Parameters("#productivity_date").Value = Trim(chdate)
main_form.cmdproductivity.Parameters("#actual_date").Value = getToday(Now)
main_form.cmdproductivity.Parameters("#total_count").Value = Trim(txtcount.Text)
main_form.cmdproductivity.Parameters("#eq_pr").Value = Trim(txtEQPRs.Text)
main_form.cmdproductivity.Parameters("#c_rebook").Value = Trim(txtrebook.Text)
main_form.cmdproductivity.Parameters("#c_nonwatson").Value = Trim(txtnonwatson.Text)
main_form.cmdproductivity.Parameters("#c_coa").Value = Trim(txtcoa.Text)
main_form.cmdproductivity.Parameters("#c_watson").Value = Trim(txtwatson.Text)
main_form.cmdproductivity.Parameters("#c_velocity").Value = Trim(txtvelocity.Text)
main_form.cmdproductivity.Parameters("#c_quote").Value = Trim(txtquote.Text)
main_form.cmdproductivity.Parameters("#c_crd").Value = Trim(txtcrd.Text)
main_form.cmdproductivity.Parameters("#c_eclaims").Value = Trim(txteclaims.Text)
main_form.cmdproductivity.Parameters("#c_ecalls").Value = Trim(txtecalls.Text)
main_form.cmdproductivity.Parameters("#c_xi").Value = Trim(txtxi.Text)
main_form.cmdproductivity.Parameters("#c_brazil").Value = Trim(txtbrazil.Text)
main_form.cmdproductivity.Parameters("#c_cancel").Value = Trim(txtcancel.Text)
main_form.cmdproductivity.Parameters("#c_queries").Value = Trim(txtqueries.Text)
main_form.cmdproductivity.Parameters("#c_partrebook").Value = Trim(txtpartrebook.Text)
main_form.cmdproductivity.Parameters("#c_nci").Value = Trim(txtnci.Text)
main_form.cmdproductivity.Parameters("#c_phil").Value = Trim(txtphil.Text)
main_form.cmdproductivity.Parameters("#c_qc").Value = Trim(txtqc.Text)
main_form.cmdproductivity.Parameters("#c_watsonqc").Value = Trim(txtwatsonqc.Text)
main_form.cmdproductivity.Parameters("#c_monitor").Value = Trim(txtmonitor.Text)
main_form.cmdproductivity.Parameters("#c_enduser").Value = Trim(txtenduser.Text)
main_form.cmdproductivity.Parameters("#c_idoc").Value = Trim(txtidoc.Text)
main_form.cmdproductivity.Parameters("#c_servercancel").Value = Trim(txtservercancel.Text)
main_form.cmdproductivity.Parameters("#eq_rebook").Value = Trim(txtEQrebook.Text)
main_form.cmdproductivity.Parameters("#eq_nonwatson").Value = Trim(txtEQnonwatson.Text)
main_form.cmdproductivity.Parameters("#eq_coa").Value = Trim(txtEQcoa.Text)
main_form.cmdproductivity.Parameters("#eq_watson").Value = Trim(txtEQwatson.Text)
main_form.cmdproductivity.Parameters("#eq_velocity").Value = Trim(txtEQvelocity.Text)
main_form.cmdproductivity.Parameters("#eq_quote").Value = Trim(txtEQquote.Text)
main_form.cmdproductivity.Parameters("#eq_crd").Value = Trim(txtEQcrd.Text)
main_form.cmdproductivity.Parameters("#eq_eclaims").Value = Trim(txtEQeclaims.Text)
main_form.cmdproductivity.Parameters("#eq_ecalls").Value = Trim(txtEQecalls.Text)
main_form.cmdproductivity.Parameters("#eq_xi").Value = Trim(txtEQxi.Text)
main_form.cmdproductivity.Parameters("#eq_brazil").Value = Trim(txtEQbrazil.Text)
main_form.cmdproductivity.Parameters("#eq_cancel").Value = Trim(txtEQcancel.Text)
main_form.cmdproductivity.Parameters("#eq_queries").Value = Trim(txtEQqueries.Text)
main_form.cmdproductivity.Parameters("#eq_partrebook").Value = Trim(txtEQpartrebook.Text)
main_form.cmdproductivity.Parameters("#eq_nci").Value = Trim(txtEQnci.Text)
main_form.cmdproductivity.Parameters("#eq_phil").Value = Trim(txtEQphil.Text)
main_form.cmdproductivity.Parameters("#eq_qc").Value = Trim(txtEQqc.Text)
main_form.cmdproductivity.Parameters("#eq_watsonqc").Value = Trim(txtEQwatsonqc.Text)
main_form.cmdproductivity.Parameters("#eq_monitor").Value = Trim(txtEQmonitor.Text)
main_form.cmdproductivity.Parameters("#eq_enduser").Value = Trim(txtEQenduser.Text)
main_form.cmdproductivity.Parameters("#eq_idoc").Value = Trim(txtEQidoc.Text)
main_form.cmdproductivity.Parameters("#eq_servercancel").Value = Trim(txtEQservercancel.Text)
Else
'main_form.cmdproductivity.CommandText = "INSERT INTO productivity " _
' & "(agent,productivity_date,actual_date,total_count,eq_pr,c_rebook,c_nonwatson,c_coa,c_watson,c_velocity,c_quote,c_crd,c_eclaims,c_ecalls,c_xi,c_brazil,c_cancel,c_queries,c_partrebook,c_nci,c_phil,c_qc,c_watsonqc,c_monitor,c_enduser,c_idoc,c_servercancel,eq_rebook,eq_nonwatson,eq_coa,eq_watson,eq_velocity,eq_quote,eq_crd,eq_eclaims,eq_ecallseq_xi,eq_brazil,eq_cancel,eq_queries,eq_partrebook,eq_nci,eq_phil,eq_qc,eq_watsonqc,eq_monitor,eq_enduser,eq_idoc,eq_servercancel VALUES" _
' & "(#agent,#productivity_date,#actual_date,#total_count,#eq_pr,#c_rebook,#c_nonwatson,#c_coa,#c_watson,#c_velocity,#c_quote,#c_crd,#c_eclaims,#c_ecalls,#c_xi,#c_brazil,#c_cancel,#c_queries,#c_partrebook,#c_nci,#c_phil,#c_qc,#c_watsonqc,#c_monitor,#c_enduser,#c_idoc,#c_servercancel,#eq_rebook,#eq_nonwatson,#eq_coa,#eq_watson,#eq_velocity,#eq_quote,#eq_crd,#eq_eclaims,#eq_ecalls,#eq_xi,#eq_brazil,#eq_cancel,#eq_queries,#eq_partrebook,#eq_nci,#eq_phil,#eq_qc,#eq_watsonqc,#eq_monitor,#eq_enduser,#eq_idoc,#eq_servercancel)"
main_form.cmdproductivity.CommandText = "INSERT INTO productivity(agent, productivity_date, actual_date, total_count, eq_pr, c_rebook, c_nonwatson, c_coa, c_watson, c_velocity, c_quote, c_crd, c_eclaims, c_ecalls, c_xi, c_brazil, c_cancel, c_queries, c_partrebook, c_nci, c_phil, c_qc, c_watsonqc, c_monitor, c_enduser, c_idoc, c_servercancel, eq_rebook, eq_nonwatson, eq_coa, eq_watson, eq_velocity, eq_quote, eq_crd, eq_eclaims, eq_ecalls, eq_xi, eq_brazil, eq_cancel, eq_queries, eq_partrebook, eq_nci, eq_phil, eq_qc, eq_watsonqc, eq_monitor, eq_enduser, eq_idoc, eq_servercancel) VALUES (#agent,#productivity_date,#actual_date,#total_count,#eq_pr,#c_rebook,#c_nonwatson,#c_coa,#c_watson,#c_velocity,#c_quote,#c_crd,#c_eclaims,#c_ecalls,#c_xi,#c_brazil,#c_cancel,#c_queries,#c_partrebook,#c_nci,#c_phil,#c_qc,#c_watsonqc,#c_monitor,#c_enduser,#c_idoc,#c_servercancel,#eq_rebook,#eq_nonwatson,#eq_coa,#eq_watson,#eq_velocity,#eq_quote,#eq_crd,#eq_eclaims,#eq_ecalls,#eq_xi,#eq_brazil,#eq_cancel,#eq_queries,#eq_partrebook,#eq_nci,#eq_phil,#eq_qc,#eq_watsonqc,#eq_monitor,#eq_enduser,#eq_idoc,#eq_servercancel)"
main_form.cmdproductivity.Parameters("#agent").Value = Trim(usr)
main_form.cmdproductivity.Parameters("#productivity_date").Value = Trim(chdate)
main_form.cmdproductivity.Parameters("#actual_date").Value = getToday(Now)
main_form.cmdproductivity.Parameters("#total_count").Value = Trim(txtcount.Text)
main_form.cmdproductivity.Parameters("#eq_pr").Value = Trim(txtEQPRs.Text)
main_form.cmdproductivity.Parameters("#c_rebook").Value = Trim(txtrebook.Text)
main_form.cmdproductivity.Parameters("#c_nonwatson").Value = Trim(txtnonwatson.Text)
main_form.cmdproductivity.Parameters("#c_coa").Value = Trim(txtcoa.Text)
main_form.cmdproductivity.Parameters("#c_watson").Value = Trim(txtwatson.Text)
main_form.cmdproductivity.Parameters("#c_velocity").Value = Trim(txtvelocity.Text)
main_form.cmdproductivity.Parameters("#c_quote").Value = Trim(txtquote.Text)
main_form.cmdproductivity.Parameters("#c_crd").Value = Trim(txtcrd.Text)
main_form.cmdproductivity.Parameters("#c_eclaims").Value = Trim(txteclaims.Text)
main_form.cmdproductivity.Parameters("#c_ecalls").Value = Trim(txtecalls.Text)
main_form.cmdproductivity.Parameters("#c_xi").Value = Trim(txtxi.Text)
main_form.cmdproductivity.Parameters("#c_brazil").Value = Trim(txtbrazil.Text)
main_form.cmdproductivity.Parameters("#c_cancel").Value = Trim(txtcancel.Text)
main_form.cmdproductivity.Parameters("#c_queries").Value = Trim(txtqueries.Text)
main_form.cmdproductivity.Parameters("#c_partrebook").Value = Trim(txtpartrebook.Text)
main_form.cmdproductivity.Parameters("#c_nci").Value = Trim(txtnci.Text)
main_form.cmdproductivity.Parameters("#c_phil").Value = Trim(txtphil.Text)
main_form.cmdproductivity.Parameters("#c_qc").Value = Trim(txtqc.Text)
main_form.cmdproductivity.Parameters("#c_watsonqc").Value = Trim(txtwatsonqc.Text)
main_form.cmdproductivity.Parameters("#c_monitor").Value = Trim(txtmonitor.Text)
main_form.cmdproductivity.Parameters("#c_enduser").Value = Trim(txtenduser.Text)
main_form.cmdproductivity.Parameters("#c_idoc").Value = Trim(txtidoc.Text)
main_form.cmdproductivity.Parameters("#c_servercancel").Value = Trim(txtservercancel.Text)
main_form.cmdproductivity.Parameters("#eq_rebook").Value = Trim(txtEQrebook.Text)
main_form.cmdproductivity.Parameters("#eq_nonwatson").Value = Trim(txtEQnonwatson.Text)
main_form.cmdproductivity.Parameters("#eq_coa").Value = Trim(txtEQcoa.Text)
main_form.cmdproductivity.Parameters("#eq_watson").Value = Trim(txtEQwatson.Text)
main_form.cmdproductivity.Parameters("#eq_velocity").Value = Trim(txtEQvelocity.Text)
main_form.cmdproductivity.Parameters("#eq_quote").Value = Trim(txtEQquote.Text)
main_form.cmdproductivity.Parameters("#eq_crd").Value = Trim(txtEQcrd.Text)
main_form.cmdproductivity.Parameters("#eq_eclaims").Value = Trim(txtEQeclaims.Text)
main_form.cmdproductivity.Parameters("#eq_ecalls").Value = Trim(txtEQecalls.Text)
main_form.cmdproductivity.Parameters("#eq_xi").Value = Trim(txtEQxi.Text)
main_form.cmdproductivity.Parameters("#eq_brazil").Value = Trim(txtEQbrazil.Text)
main_form.cmdproductivity.Parameters("#eq_cancel").Value = Trim(txtEQcancel.Text)
main_form.cmdproductivity.Parameters("#eq_queries").Value = Trim(txtEQqueries.Text)
main_form.cmdproductivity.Parameters("#eq_partrebook").Value = Trim(txtEQpartrebook.Text)
main_form.cmdproductivity.Parameters("#eq_nci").Value = Trim(txtEQnci.Text)
main_form.cmdproductivity.Parameters("#eq_phil").Value = Trim(txtEQphil.Text)
main_form.cmdproductivity.Parameters("#eq_qc").Value = Trim(txtEQqc.Text)
main_form.cmdproductivity.Parameters("#eq_watsonqc").Value = Trim(txtEQwatsonqc.Text)
main_form.cmdproductivity.Parameters("#eq_monitor").Value = Trim(txtEQmonitor.Text)
main_form.cmdproductivity.Parameters("#eq_enduser").Value = Trim(txtEQenduser.Text)
main_form.cmdproductivity.Parameters("#eq_idoc").Value = Trim(txtEQidoc.Text)
main_form.cmdproductivity.Parameters("#eq_servercancel").Value = Trim(txtEQservercancel.Text)
End If
Catch ex As Exception
MsgBox("Database Error: " & ex.ToString() & vbCrLf & "The error have been logged .... ", MsgBoxStyle.OkOnly, main_form.dbErrTitle)
writeLogs("Database Error: " & ex.ToString())
Finally
main_form.mySQLconn1.Close()
End Try
Return True
End Function
I don't calculate your column number, but do you miss one column at end? where is the last id which exists in column but not in VALUSE part:
(eq_servercancel, id) vs
(#eq_servercancel)
It would really help if you edit your answer with the error you are getting, but at a glance:
You are adding "id" to you column list in the INSERT statement, but you do not have a "id" value in your VALUES statement. So either remove "id" from the INSERT statement or send through a value for "id".

Using linebreak to break IF statement in Access VBA

I have a VBA conditional script as below:
If COMORBIDITY_CANCER = -1 Or COMORBIDITY_CHRONIC_SKIN_LESIONS = -1 Or COMORBIDITY_CHRONIC_LUNG_DISEASE = -1 Or COMORBIDITY_CARDIOVASCULAR_DISEASE = -1 Or COMORBIDITY_DM = -1 Or COMORBIDITY_IMMUNODEFICIENCY_OR_CHEMOTHERAPY = -1 Or COMORBIDITY_ADL = -1 Or COMORBIDITY_HEPATIC_DISEASE = -1 Or COMORBIDITY_RENAL_IMPAIRMENT = -1 Then
RS_REPORT.AddNew
RS_REPORT!REPORT_UID = REPORT_UID
RS_REPORT!CATEGORY1_ID = 2
RS_REPORT!CATEGORY2_ID = 1
RS_REPORT!CATEGORY3_ID = 1
RS_REPORT.Update
End If
I think the first line of it is too long and I would like to chop it using ENTER, like what can be done in R, but seems it is invalid in VBA, I tried
& _
but it also fails.
Any suggestions? Thanks!
Try this:
If COMORBIDITY_CANCER = -1 Or COMORBIDITY_CHRONIC_SKIN_LESIONS = -1 Or _
COMORBIDITY_CHRONIC_LUNG_DISEASE = -1 Or COMORBIDITY_CARDIOVASCULAR_DISEASE = -1 Or _
COMORBIDITY_DM = -1 Or COMORBIDITY_IMMUNODEFICIENCY_OR_CHEMOTHERAPY = -1 Or _
COMORBIDITY_ADL = -1 Or COMORBIDITY_HEPATIC_DISEASE = -1 Or _
COMORBIDITY_RENAL_IMPAIRMENT = -1 Then
You could try something such as:
Boolean b = false
If condition1 b = true
If condition2 b = true
. . .
If b ...