Runtime Error 3061 VBA using Insert command - ms-access

I have the following code. I am using a form in MS Access 2010 to enter new lines into my table Nlog. When I try to run the code, it gives me the error Run-Time error '3061': Too few parameters. Expected 1.
I can't find the error!
Private Sub Command128_Click()
'add data to table
CurrentDb.Execute "INSERT INTO NLog(IDKEY, Company, CoName, State, City, AmtpdTotal, DateRec, Notified, DateNotice, AcctID, TaxType, Period, NoticeReason, Resolution, TaxDue, Intdue, PenDue, Dateres, Amtpdint, amtpdpen, amtpdtax, Assigned, subAssgn, Resolved) " & _
" VALUES(" & Me.TxtIDKEY & ",'" & Me.Company & "','" & Me.CoName & "','" & _
Me.State & "','" & Me.City & "','" & Me.TxtAmtpdTotal & "','" & _
Me.DateRec & "','" & Me.Notified & "','" & _
Me.DateNotice & "','" & Me.AcctID & "','" & Me.TaxType & "','" & Me.Period & "','" & _
Me.NoticeReason & "','" & Me.Resolution & "','" & Me.TaxDue & "','" & Me.IntDue & "','" & Me.PenDue & "','" & _
Me.DateRes & "','" & Me.AmtPdInt & "','" & Me.AmtpdPen & "','" & Me.AmtpdTax & "','" & _
Me.Assigned & "','" & Me.txtsubass & "','" & Me.Resolved & "')", dbFailOnError
MsgBox ("Entry Added")

Use a string variable to hold the INSERT statement. That allows you to Debug.Print the string so you can inspect the actual statement your code created. And you can Execute the string.
Dim strInsert As String
strInsert = "INSERT INTO NLog(IDKEY, Company, CoName, State, City, AmtpdTotal, DateRec, Notified, DateNotice, AcctID, TaxType, Period, NoticeReason, Resolution, TaxDue, Intdue, PenDue, Dateres, Amtpdint, amtpdpen, amtpdtax, Assigned, subAssgn, Resolved) " & _
" VALUES(" & Me.TxtIDKEY & ",'" & Me.Company & "','" & Me.CoName & "','" & _
Me.State & "','" & Me.City & "','" & Me.TxtAmtpdTotal & "','" & _
Me.DateRec & "','" & Me.Notified & "','" & _
Me.DateNotice & "','" & Me.AcctID & "','" & Me.TaxType & "','" & Me.Period & "','" & _
Me.NoticeReason & "','" & Me.Resolution & "','" & Me.TaxDue & "','" & Me.IntDue & "','" & Me.PenDue & "','" & _
Me.DateRes & "','" & Me.AmtPdInt & "','" & Me.AmtpdPen & "','" & Me.AmtpdTax & "','" & _
Me.Assigned & "','" & Me.txtsubass & "','" & Me.Resolved & "')"
Debug.Print strInsert
CurrentDb.Execute strInsert, dbFailOnError
You can then view the completed statement (the output from Debug.Print) in the Immediate window. Ctrl+g will take you to the Immediate window.
If the error is not obvious, you can copy the statement text, create a new query in the query designer, switch it to SQL View, and paste in the copied statement. When you try to run that query from the designer, Access will display a parameter dialog which asks you to supply a value for the parameter. Notice that dialog also includes the "name" of the parameter. Frequently the cause of this problem is a misspelled field name --- since Access can't find a field by that name, it assumes it must be a parameter instead.
Alternatively, you can use VBA code to show you the names of any parameters in your query:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Set db = CurrentDb
Set qdf = db.CreateQueryDef(vbNullString, strInsert)
For Each prm In qdf.Parameters
Debug.Print prm.Name
Next

Related

Update subform after information is added

So here's my problem I can get my subform to requery once but that is it I can't get it to requery after new information is entered. Can someone please help! I have tried using RecordsetClone and that didn't work as well as other suggestions and I haven't been able to get anything to work
Private Sub cmdAdd_Click()
CurrentDb.Execute "INSERT INTO tbl_GroupVolunteers (GroupName, Leader,
VolunteerName, Email, Phone, EmergencyContact, EmergencyNumber,
NumberofVolunteers, RegistrationNumber)" & _
"VALUES ('" & Me.txtGroupName & "','" & Me.cboLeader & "','" &
Me.txtVolunteerName & "','" & Me.txtEmail & "','" & Me.txtPhone & "','" &
Me.txtEmergencyContact & _
"','" & Me.txtEmergencyNumber & "','" & Me.txtNumberofVolunteers & "','" &
Me.txtRegistrationNumber & "')"
'refresh data
Me!subformGroupVolunteers.Form.Requery
'Clear form
cmdClear_Click
End Sub
Put a break in your code and step through it to see where it's failing. I'd suggest separating the Execute function. Something like this:
Dim sqlStr as String
sqlStr = "INSERT INTO tbl_GroupVolunteers (GroupName, Leader,
VolunteerName, Email, Phone, EmergencyContact, EmergencyNumber,
NumberofVolunteers, RegistrationNumber)" & _
"VALUES ('" & Me.txtGroupName & "','" & Me.cboLeader & "','" &
Me.txtVolunteerName & "','" & Me.txtEmail & "','" & Me.txtPhone & "','" &
Me.txtEmergencyContact & _
"','" & Me.txtEmergencyNumber & "','" & Me.txtNumberofVolunteers & "','" &
Me.txtRegistrationNumber & "')"
CurrentDb.Execute sqlStr
'refresh data
Me!subformGroupVolunteers.Form.Requery
'Clear form
cmdClear_Click
Or instead of stepping through it, you can add a messagebox like this:
Dim sqlStr as String
sqlStr = "INSERT INTO tbl_GroupVolunteers (GroupName, Leader,
VolunteerName, Email, Phone, EmergencyContact, EmergencyNumber,
NumberofVolunteers, RegistrationNumber)" & _
"VALUES ('" & Me.txtGroupName & "','" & Me.cboLeader & "','" &
Me.txtVolunteerName & "','" & Me.txtEmail & "','" & Me.txtPhone & "','" &
Me.txtEmergencyContact & _
"','" & Me.txtEmergencyNumber & "','" & Me.txtNumberofVolunteers & "','" &
Me.txtRegistrationNumber & "')"
Msgbox sqlStr 'Display the string
CurrentDb.Execute sqlStr
'refresh data
Me!subformGroupVolunteers.Form.Requery
'Clear form
cmdClear_Click
This way, you can step through the variable and make sure the string that gets created is functioning properly. If records aren't being added correctly, then it's probably because that INSERT INTO statement isn't pulling in the data properly.

Insert into query from form when date field is empty

In MS Access, I have an unbound form with, among others, two fields with a format of "short date" so I can get the date picker to show (Access 2007).
On click of a button, the data is inserted into a table using this sql query in vba
strInsert = "INSERT INTO atbl_invoice (cust_id, inv_date, job_no, item_desc, job_desc, type, fday, reqday) " & _
"VALUES(" & strCid & ", Date(),'" & Me.JobNo & "','" & Me.item_desc & "','" & Me.job_desc & "','" & Me.cboType & "','" & Me.fday & "','" & Me.reqday & "')"
fday and reqday in the table are time/date fields and are set to 'required=No'.
All goes fine if the two date fields on the form are filled in, but if either of them is left empty, I get a "set 1 fields to Nul due to a type conversion failure" error because it is trying to put an empty string into a date/time field.
Does any one know of a way that I can leave these fields blank and still have my insert query work?
THANKS for the help.
In case anyone is wondering, this is how I ended up doing it.
Dim strInsert0 As String
Dim strInsert1 As String
Dim strInsert2 As String
Dim strInsert3 As String
Dim strCid As String
strCid = Forms!frmCustomer!cid
strInsert0 = "INSERT INTO atbl_invoice (cust_id, inv_date, job_no, item_desc, job_desc, type) " & _
"VALUES(" & strCid & ", Date(),'" & Me.JobNo & "','" & Me.item_desc & "','" & Me.job_desc & "'," & _
"'" & Me.cboType & "')"
strInsert1 = "INSERT INTO atbl_invoice (cust_id, inv_date, job_no, item_desc, job_desc, type, fday) " & _
"VALUES(" & strCid & ", Date(),'" & Me.JobNo & "','" & Me.item_desc & "','" & Me.job_desc & "'," & _
"'" & Me.cboType & "','" & Me.fday & "')"
strInsert2 = "INSERT INTO atbl_invoice (cust_id, inv_date, job_no, item_desc, job_desc, type, reqday) " & _
"VALUES(" & strCid & ", Date(),'" & Me.JobNo & "','" & Me.item_desc & "','" & Me.job_desc & "'," & _
"'" & Me.cboType & "','" & Me.reqday & "')"
strInsert3 = "INSERT INTO atbl_invoice (cust_id, inv_date, job_no, item_desc, job_desc, type, fday, reqday) " & _
"VALUES(" & strCid & ", Date(),'" & Me.JobNo & "','" & Me.item_desc & "','" & Me.job_desc & "'," & _
"'" & Me.cboType & "','" & Me.fday & "','" & Me.reqday & "')"
If IsNull(Me.reqday) And Not IsNull(Me.fday) Then
DoCmd.RunSQL strInsert1
ElseIf IsNull(Me.fday) And Not IsNull(Me.reqday) Then
DoCmd.RunSQL strInsert2
ElseIf IsNull(Me.reqday) And IsNull(Me.fday) Then
DoCmd.RunSQL strInsert0
Else: DoCmd.RunSQL strInsert3
End If
Having the two date fields, either of which could have been empty or not, complicated it a little.
I am not sure, but I believe you cannot store null values. If I were you, I would run an if statement to check if they are null. Check out this code below:
if len(me.fday.value) > 0 and len(me.reqday.value) > 0 then
strInsert = "INSERT INTO atbl_invoice (cust_id, inv_date, job_no, item_desc, job_desc, type, fday, reqday) " & _ "VALUES(" & strCid & ", Date(),'" & Me.JobNo & "','" & Me.item_desc & "','" & Me.job_desc & "','" & Me.cboType & "','" & Me.fday & "','" & Me.reqday & "')"
else
strInsert = "INSERT INTO atbl_invoice (cust_id, inv_date, job_no, item_desc, job_desc, type) " & _ "VALUES(" & strCid & ", Date(),'" & Me.JobNo & "','" & Me.item_desc & "','" & Me.job_desc & "','" & Me.cboType & "')"
end if
See if this works, if it doesn't, comment on the answer and let me know.
In the sql string use the following query:
insert into mytable (mydata) values (#01/01/2020#)
or
insert into mytable (mydata) values (NULL)

Runtime error 3075 can't figure it out

I'm trying to do an insert on a button click event and I keep getting a runtime error of missing operator in query expression my query looks like the following. Any ideas?
Private Sub CmdAdd_Click()
Dim strSql As String
strSql = "INSERT INTO Current_Costs(PO_Number,Lineitemid,Capital_detail,CapitalID,GL_Number,Cost_Type,Cost_Center,Cost_cat,Item_Cost,PO_Date)" & _
" VALUES (" & Me.txtPONum & "','" & _
Me.cmbCapDetail & "','" & _
Me.cmbCapDetail.Column(1) & "','" & _
Me.txtCapID & "','" & _
Me.txtGLNum & "','" & _
Me.cmbCostType & "','" & _
Me.txtCostCen & "','" & _
Me.cmbCostCat & "','" & _
Me.txtCost & "','" & _
Me.TxtPODate & "')"
DoCmd.RunSQL strSql
i have a similar query that has the same issue and i cant see the problem
CurrentDb.Execute ("UPDATE Current_Costs " & _
"SET PO_Number='" & Me.txtPONum & "'" & _
",Lineitemid='" & Me.cmbCapDetail & "'" & _
",Capital_detail='" & Me.cmbCapDetail.Column(1) & "'" & _
",CapitalID='" & Me.txtCapID & "'" & _
",GL_Number='" & Me.txtGLNum & "'" & _
",Cost_Type='" & Me.cmbCostType & "'" & _
",Cost_Center='" & Me.txtCostCen & "'" & _
",Cost_cat='" & Me.cmbCostCat & "'" & _
",Item_Cost='" & Me.txtCost & "'" & _
",PO_Date='" & Me.TxtPODate & "'" & _
"WHERE LineItemPOID=" & Me.txtID.Tag)
edit solved
This
" VALUES (" & Me.txtPONum & "','" & _
Is short one quote, it should be
" VALUES ('" & Me.txtPONum & "','" & _
Write your sql in a string, it makes it easier to see the problems:
strSql = "UPDATE Current_Costs " & _
"SET PO_Number='" & txtPONum & "'" & _
",Lineitemid='" & cmbCapDetail & "'" & _
",Capital_detail='" & cmbCapDetail.Column(1) & "'" & _
",CapitalID='" & txtCapID & "'" & _
",GL_Number='" & txtGLNum & "'" & _
",Cost_Type='" & cmbCostType & "'" & _
",Cost_Center='" & txtCostCen & "'" & _
",Cost_cat='" & cmbCostCat & "'" & _
",Item_Cost='" & txtCost & "'" & _
",PO_Date='" & TxtPODate & "'" & _
" WHERE LineItemPOID=" & txtID
Dim db As database
Set db = CurrentDB
db.Execute strsql dbFailOnError
You were missing a space before WHERE and you had an unmatched parenthesis.
Consider using parameters: End of statement error

how to vb.net date save to mysql date with no 0000-00-00

I've been killing brain cell for over 5 hours with this question.
how to properly save a date from vb.net to mysql date without getting the 0000-00-00all the time.
I have tried multiple suggestions where you format the date value before entering but it gets me the same result ex:
Dim departDate As Date
Dim d As String = Format(departDate, "05/05/2007")
in which i tested and didnt works i still got the 0000-00-00
I've tried:
Dim changeFormatDate As Date
Dim AddFechaListadoCasas2 as String
changeFormatDate = AddCasasListadoDatePicker.Text
AddFechaListadoCasas2 = changeFormatDate.ToString("yyyy-MM-dd")
which still gives me on mysql the 0000-00-00
I also tried this example:
Dim myDate as DateTime = DateTime.ParseExact(x, "yyyy-MM-dd", CultureInfo.CurrentCulture)
and trying to save to mysql still gave me the 0000-00-00
in my program im grabbing the date from a datepicker as text then swtich it to a string and try to save it to the database like that. if necessary i would love to convert it to a date with the format yyyy-MM-dd which is necessary for MySQL but everything i've done above it still shows me the 0000-00-00 which is frustrating.
any help would be very appreciated it.
Leo
here is the MySQL insert statement i have on my program.
AddFechaListadoCasas2 = AddCasasListadoDatePicker.Text
AddFechaCierreCasas2 = AddFechaCierreCasas.Text
SqlVentaCasas = "INSERT INTO VentaCasas (ID, Direccion, Ciudad_Municipio, Zona_Localidad, Barrio, " & _
"Estatus, Precio, Unidad, Departamento, Conjunto, Estrato, Matricula_Inmobiliaria, Cedula_Catastral," & _
"Escritura, Notaria, Ano, Area_Metros_2, Tipo_de_Construccion, Niveles, Habitaciones, Garajes," & _
"Techo, Vista, Picina, Cocina_Integral, Bar, Cuarto_Bano_Servicio, Antejardin, Equipos," & _
"Aire_Acondicionado, Detalles_addicionales, Estilo, Ano_Construccion, Orientacion, Banos, Parqueos," & _
"Piso, Balcon, Jacuzzi_Sauna, Chimenea, Hall_Television, Zona_lavanderia, Patio, Accesorios," & _
"Calefaccion, Administracion, Amenidades, Impuestos, Condiciones, Ocupacion," & _
"Cuota_Administracion, Restricciones, Seguridad, Mostrar, Comision, Fecha_Listado, " & _
"Agente_Cooperante, Fecha_Expiracion, CiudadEscritura, Agente, Licensia, Compania, NumeroPersonal," & _
"NumeroCompania, NumeroFax, Email, AreaLotesM2, PrecioOriginal, Account_Creator, NumeroDias ) VALUES ('" & _
AddIDCasas2 & "','" & _
AddDireccionCasas2 & "','" & AddCiudadCasas2 & "','" & AddZonaCasas2 & "','" & AddBarrioCasas2 & "','" & _
AddEstatusCasas2 & "'," & AddPrecioCasas2 & ",'" & AddUnidadCasas2 & "','" & AddDepartamentoCasas2 & "','" & _
AddConjuntoCasas2 & "'," & AddEstratoCasas2 & ",'" & AddMatriculaCasas2 & "','" & _
AddCedulaCatastralCasas2 & "','" & AddEscrituraCasas2 & "','" & AddNotariaCasas2 & "'," & _
AddAnoCasas2 & "," & AddMetros2Casas2 & ",'" & AddTipoConstruccionCasas2 & "'," & _
AddNivelesCasas2 & "," & AddHabitacionesCasas2 & "," & AddGarajesCasas2 & ",'" & _
AddTechoCasas2 & "','" & AddVistaCasas2 & "','" & AddPicinaCasas2 & "','" & AddCocinaIntegralCasas2 & "','" & _
AddBarCasas2 & "','" & AddCuartoCasas2 & "','" & AddAnteJardinCasas2 & "','" & AddEquiposCasas2 & "','" & _
AddAireAcondicionadoCasas2 & "','" & AddDetallesAddicionalesCasas2 & "','" & AddEstiloCasas2 & "'," & _
AddAnoConstruccionCasas2 & ",'" & AddOrientacionCasas2 & "'," & AddBanoCasas2 & "," & _
AddParqueoCasas2 & ",'" & AddPisoCasas2 & "','" & AddBalconCasas2 & "','" & AddJacuzziCasas2 & "','" & _
AddChimeneaCasas2 & "','" & AddTVCasas2 & "','" & AddZonaLavanderiaCasas2 & "','" & AddPatioCasas2 & "','" & _
AddAccesoriosCasas2 & "','" & AddCalefaccionCasas2 & "','" & AddAdministracionCasas2 & "','" & _
AddAmenidadesCasas2 & "','" & AddImpuestosCasas2 & "','" & AddCondicionesCasas2 & "','" & _
AddOcupacionCasas2 & "','" & AddCuotaAdministracionCasas2 & "','" & AddRestriccionesCasas2 & "','" & _
AddSeguridadCasas2 & "','" & AddMonstrarCasas2 & "','" & AddComisionCasas2 & "','" & _
AddFechaListadoCasas2 & "','" & AddAgenteCooperanteCasas2 & "','" & _
AddFecdhaExpiracionCasas2 & "','" & _
AddCiudadEscrituraCasas2 & "','" & AgenteNameCasas2 & "','" & _
AgenteLicensiaCasas2 & "','" & AgenteCompaniaCasas2 & "','" & _
AgentePersonalCasas2 & "','" & AgenteTelefonoCasas2 & "','" & _
AgenteFaxCasas2 & "','" & AgenteEmailCasas2 & "'," & AddAreaLotesM2Casas2 & "," & AddPrecioOriginalCasas2 & ", '" & AgenteAccountCreatorCasas2 & "', 0 );"
AddFechaListadoCasas2 and AddFecdhaExpiracionCasas2 are Strings that contains the date i want to input on MySQL
Your current query is vulnerable with SQL Injection. Please make use of ADONet Object such as Connection and Command with parameters. To be more specific, since you are using MySQL, use MySQL Data provider. It will automatically cast the data types for you.
Dim query As String = "INSERT INTO tableName (dateColumn) VALUES (#dateParam)"
Using conn As New MySqlConnection("connectionstringHere")
Using comm As New MySqlCommand()
With comm
.Connection = conn
.CommandText = query
.CommandType = Commandtype.Text
' Assuming this is a DatePicker '
.Parameters.AddWithValue("#dateParam", AddCasasListadoDatePicker.Value)
End With
Try
conn.Open()
comm.ExecuteNonQuery()
Catch(ex as MySqlException)
Msgbox(ex.Message.ToString())
End Try
End Using
End Using

Access Database not inserting records

Solved: i just managed to solve the problem by creating a new table and removing [IT-DEC], [IT-DEC-MAKER-FNAME], [IT-DEC-MAKER-LNAME] where i replaced them by strings accepted by access such as ITDECMAKER ITDECMAKEFNAME ITDECMAKERLNAME
Looks like the problem is solved, however if anyone has a theory to why this has happened id really appreciate your contribution
thank you
I am facing trouble with inserting more than one line of data into my table. For example i load my form and input the data into textbox all information are inserted into their respective tables accordingly, however for the second time when i want to insert data, all data are inserted succesffuly in their respective tables except for one table which is not taking any more data thus only allowing for one line of data.
This is the code i am using in the same form
This part of code is responsible for the userinfo table which is not accepting more than one record
Private Sub proceedBTN_Click()
GlobalVar.flp = Me.qfirstname + Me.qlastname + Me.qmobile
CurrentDb.Execute "INSERT INTO UserInfo(" _
& "FLP, FirstName, LastName, Company, JobTitle, PhoneNumber, Mobile, Email, Fax, " _
& "[IT-DEC], [IT-DEC-MAKER-FNAME], [IT-DEC-MAKER-LNAME], Contact, ContactMethodPhone, " _
& "ContactMethodEmail, ContactMethodFax, ContactMethodPostal , AcquisitionTimeFrame, Budget ) " _
& "VALUES('" & GlobalVar.flp & "','" & Me.qfirstname & "','" & Me.qlastname & "','" & Me.qcompany & "','" & Me.qjob & "','" & Me.qphone & "','" & Me.qmobile & "','" & Me.qemail & "','" _
& Me.qfax & "','" & Me.itdecopt & "','" & Me.qitfirstname & "','" & Me.qitlastname & "','" & Me.contactoption & "','" _
& Me.contactphoneopt & "','" & Me.contactemailopt & "','" & Me.contactfaxopt & "','" & Me.contactpostalopt & "','" & Me.acquisitionoption & "','" & Me.budgetoption & "');"
This Code is responsible for inserting into the UserPartners table which allows succesffuly entering multiple records.
CurrentDb.Execute "INSERT INTO UserPartners(" _
& "FLP, PartnerACT, PartnerBMB, PartnerEverTeam, " _
& "PartnerFormatech, PartnerICC, PartnerIBS, PartnerMegaTek, PartnerMDS, PartnerProcomix, PartnerSetsSolutions, " _
& "PartnerTripleC, PartnerNewHorizons, PartnerPromethean, PartnerTeletrade, PartnerNokia, PartnerPolycom, PartnerDell ) " _
& "VALUES('" & GlobalVar.flp & "','" & Me.partneract & "','" & Me.partnerbmb & "','" _
& Me.partnereverteam & "','" & Me.partnerformatech & "','" & Me.partnericc & "','" & Me.partneribs & "','" & Me.partnermegatek & "','" & Me.partnermds & "','" _
& Me.partnerprocomix & "','" & Me.partnersetssolutions & "','" & Me.partnertriplec & "','" & Me.partnernewhorizons & "','" & Me.partnerpromethean & "','" _
& Me.partnerteletrade & "','" & Me.partnernokia & "','" & Me.partnerpolycom & "','" & Me.partnerdell & "');"
Finally this is the code for the whole form
Option Compare Database
Private Sub contactoption_Click()
If Me.contactoption.Value = 2 Then
Me.contactemailopt.Enabled = False
Me.contactfaxopt.Enabled = False
Me.contactphoneopt.Enabled = False
Me.contactpostalopt.Enabled = False
Me.partneract.Enabled = False
Me.partnerbmb.Enabled = False
Me.partnerdell.Enabled = False
Me.partneredm.Enabled = False
Me.partnereverteam.Enabled = False
Me.partnerformatech.Enabled = False
Me.partneribs.Enabled = False
Me.partnericc.Enabled = False
Me.partnermds.Enabled = False
Me.partnermegatek.Enabled = False
Me.partnernewhorizons.Enabled = False
Me.partnernokia.Enabled = False
Me.partnerpolycom.Enabled = False
Me.partnerprocomix.Enabled = False
Me.partnerpromethean.Enabled = False
Me.partnersetssolutions.Enabled = False
Me.partnerteletrade.Enabled = False
Me.partnertriplec.Enabled = False
Else: Me.contactemailopt.Enabled = True
Me.contactfaxopt.Enabled = True
Me.contactphoneopt.Enabled = True
Me.contactpostalopt.Enabled = True
Me.partneract.Enabled = True
Me.partnerbmb.Enabled = True
Me.partnerdell.Enabled = True
Me.partneredm.Enabled = True
Me.partnereverteam.Enabled = True
Me.partnerformatech.Enabled = True
Me.partneribs.Enabled = True
Me.partnericc.Enabled = True
Me.partnermds.Enabled = True
Me.partnermegatek.Enabled = True
Me.partnernewhorizons.Enabled = True
Me.partnernokia.Enabled = True
Me.partnerpolycom.Enabled = True
Me.partnerprocomix.Enabled = True
Me.partnerpromethean.Enabled = True
Me.partnersetssolutions.Enabled = True
Me.partnerteletrade.Enabled = True
Me.partnertriplec.Enabled = True
End If
End Sub
Private Sub itdecopt_Click()
If Me.itdecopt.Value = 1 Then
Me.qitfirstname.Enabled = False
Me.qitlastname.Enabled = False
Else: Me.qitfirstname.Enabled = True
Me.qitlastname.Enabled = True
End If
End Sub
Private Sub proceedBTN_Click()
GlobalVar.flp = Me.qfirstname + Me.qlastname + Me.qmobile
CurrentDb.Execute "INSERT INTO UserInfo(" _
& "FLP, FirstName, LastName, Company, JobTitle, PhoneNumber, Mobile, Email, Fax, " _
& "[IT-DEC], [IT-DEC-MAKER-FNAME], [IT-DEC-MAKER-LNAME], Contact, ContactMethodPhone, " _
& "ContactMethodEmail, ContactMethodFax, ContactMethodPostal , AcquisitionTimeFrame, Budget ) " _
& "VALUES('" & GlobalVar.flp & "','" & Me.qfirstname & "','" & Me.qlastname & "','" & Me.qcompany & "','" & Me.qjob & "','" & Me.qphone & "','" & Me.qmobile & "','" & Me.qemail & "','" _
& Me.qfax & "','" & Me.itdecopt & "','" & Me.qitfirstname & "','" & Me.qitlastname & "','" & Me.contactoption & "','" _
& Me.contactphoneopt & "','" & Me.contactemailopt & "','" & Me.contactfaxopt & "','" & Me.contactpostalopt & "','" & Me.acquisitionoption & "','" & Me.budgetoption & "');"
CurrentDb.Execute "INSERT INTO UserPartners(" _
& "FLP, PartnerACT, PartnerBMB, PartnerEverTeam, " _
& "PartnerFormatech, PartnerICC, PartnerIBS, PartnerMegaTek, PartnerMDS, PartnerProcomix, PartnerSetsSolutions, " _
& "PartnerTripleC, PartnerNewHorizons, PartnerPromethean, PartnerTeletrade, PartnerNokia, PartnerPolycom, PartnerDell ) " _
& "VALUES('" & GlobalVar.flp & "','" & Me.partneract & "','" & Me.partnerbmb & "','" _
& Me.partnereverteam & "','" & Me.partnerformatech & "','" & Me.partnericc & "','" & Me.partneribs & "','" & Me.partnermegatek & "','" & Me.partnermds & "','" _
& Me.partnerprocomix & "','" & Me.partnersetssolutions & "','" & Me.partnertriplec & "','" & Me.partnernewhorizons & "','" & Me.partnerpromethean & "','" _
& Me.partnerteletrade & "','" & Me.partnernokia & "','" & Me.partnerpolycom & "','" & Me.partnerdell & "');"
CurrentDb.Execute "INSERT INTO UserProducts(" _
& "FLP, ProductsExchange,ProductsLyncServer, ProductsLync , ProductsOffice, ProductsSharePoint, ProductsSharePointInternet, ProductsWindowsServer, " _
& "ProductsSystemCenter, ProductsSQL, ProductsWindows7 ) " _
& "VALUES('" & GlobalVar.flp & "','" & Me.productexchange & "','" & Me.productlyncserver & "','" _
& Me.productlync & "','" & Me.productoffice & "','" & Me.productsharepoint & "','" & Me.productsharepointinternet & "','" & Me.productserver & "','" & Me.productsystemcenter & "','" _
& Me.productsql & "','" & Me.productwindows & "');"
DoCmd.OpenForm "DayChoose", acNormal
DoCmd.Close acForm, "UserInfo", acSaveYes
End Sub
Before I can help you, please rework using parameters as follows:
Private Sub proceedBTN_Click()
Dim Db As DAO.Database
Set Db = CurrentDb
Dim qd As DAO.QueryDef
Dim SQL As String
SQL = "INSERT INTO UserInfo(" & _
"FLP, FirstName, LastName, Company, JobTitle, PhoneNumber, Mobile, Email, Fax, " & _
"[IT-DEC], [IT-DEC-MAKER-FNAME], [IT-DEC-MAKER-LNAME], Contact, ContactMethodPhone, " & _
"ContactMethodEmail, ContactMethodFax, ContactMethodPostal , AcquisitionTimeFrame, Budget) " & _
"VALUES([pflp], [pfirstname], [pqlastname], [pqcompany],[pqjob],[pqphone],[pqmobile], [pqemail]," & _
"[pqfax],[pitdecopt],pqitfirstname,[pqitlastname],[pcontactoption],[pcontactphoneopt],[pcontactemailopt]," & _
"[pcontactfaxopt],[pcontactpostalopt],[pacquisitionoption],[pbudgetoption]);"
Set qd = Db.CreateQueryDef("", SQL)
qd.Parameters("pflp") = GlobalVar.flp
qd.Parameters("pfirstname") = Me.qfirstname
' continue filling parameters....
qd.Parameters("pbudgetoption").Value = Me.budgetoption
qd.Execute
End Sub
If this does not resolve your issue, we can dig a little deeper.