ms access 2007 - Insert Into SQL not working -


i have table named cpns fields c_bk_no (coupon book number), st_no (starting coupon number) , end_no (number of last coupon) integers.

i have initiated table first record 1, 1, 25.

i trying system insert new rows cpn number + 1, start_no + 25 , end_no + 25 new record on clicking button (command13) on form.

thus, expected second record should have cpn_bk_no = 2, st_no = 26, end_no = 50.

i not sure why following sql not working:

private sub command13_click()     dim sql string     dim cbkno long     dim stno long     dim endno long      cbkno = me![c_bk_no].value + 1     stno = me![st_no].value + 25     endno = me![end_no].value + 25      sql = "insert cpns ([c_bk_no], [st_no], [end_no]); values (cbkno, stno, endno))"      currentdb.execute sql  end sub 

every time click button, says "run time error 3061, few parameters: expected 3." , line "currentdb.execute sql" highlighted in yellow.

please can help?

it's difficult know begin this, basic problem you're facing you've typed names of variables string. unlike other languages, vb doesn't @ string contents , think "oh, he's typed variable name string, i'll jut swap value in variable"

there other problems code too, not quite fundamental that. i'd genuinely recommend throw code away , follow tutorial instead, how access database in 1 of ways microsoft recommends:

https://msdn.microsoft.com/en-us/library/ms171884.aspx

even if you're not making win forms app concepts there inside can applied kinds of app


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -