What's Wrong with this CODE!?!?!!?

OscarAGC5

New member
Local time
Today, 00:49
Joined
Apr 23, 2015
Messages
6
So I'm trying to populate a table based on selections I make within a form.

The form is based of a query that pulls a new product category that needs to be added to my first reference table for products.

The form shows all the new unique product codes, and there is a drop down box with product categories whose source is also the first reference table, so a new code would be:

'JBL - TRX - FVB - TRZ' And based on that new info, I would select from the drop down to select the corresponding category and click 'Add Record' button.

I'm building the event for the button and the code is as follows so far :

Private Sub Add_Record_Click()
End Sub
Private Sub cmbAdd_Record_Click()
'add data to table
CurrentDb.Execute "INSERT INTO tblPVMTable(PVMJoinField, SummaryPVMCategory) " & _
" VALUES(" & Me.PVM_JOIN_FIELD & ", '" & _
Me.cboSummaryPVMCategory & "' , "


'refresh data in list on form
frmPVMTablesub.Form.Requery

End Sub
Private Sub Combo2_Click()
End Sub
Private Sub Toggle4_Click()
End Sub


I keep getting errors with the main portion of code.:banghead:

Name of table fields :

PVMJoinField
SummaryPVMCategory

Name of Query Fields Populating the Form:

PVM_JOIN_FIELD
cboSummaryPVMCategory

Thanks to All in ADVANCE!:D
 
When you build code that builds code and something goes wrong with the code, you need to find out what that code is. Confusing? Good.

Here's what I mean. Inside your VBA code, you are constructing SQL code. Since something is going wrong with your VBA code, you need to make sure the SQL code you are constructing is actually valid SQL code. You do that by visually inspecting the SQL code. Spit it out and see what it says instead of hoping its right when you execute it.

If it looks good, take it and paste it into a query object and run it, if it runs it means your SQL is good and the problem is in the VBA code, if it doesn't, well you've narrowed down the problem. (Hint, its the SQL code).
 
I don't know how to do that :confused: - I'm just starting out with code :(- I'm just watching videos and trying to emulate what I see is working for others.

I'm looking for some good resources to learn from, but I'm trying to make this work now to start.

Any suggestions ?
 

Users who are viewing this thread

Back
Top Bottom