| Author |
Topic |
|
eadward
Starting Member
6 Posts |
Posted - 2006-05-10 : 10:23:46
|
| Hi!I'm trying to make an access form to add registers to a table, nut I receive some problems. This is the code:DoCmd.RunSQL ("insert into custom(date,concept,inv,inv2,out,buy,bq) values (""&me.date&"",""&me.concept&"",""&me.inv&"",""&me.inv2&"",""&me.out&"",""&me.buy.text&"",""&me.bq.text&"");")There date, concept, inv, inv2 and out are "text fields" linked to the 'custom' table, and buy and bq are combobox.1-The register is added correctly, but the first one is erased too. The 'custom' table does not have a primary key defined, but I think that's not the problem.2-I tried the calling to me.forms with some variations, but it keeps rewriting the register or it rewrites the register adding the 'me.date' (as a text, not the me.date content)If someone knows where I'm messing up, please, help me to fix it.Thanks |
|
|
KenW
Constraint Violating Yak Guru
391 Posts |
Posted - 2006-05-10 : 10:50:40
|
quote: DoCmd.RunSQL ("insert into custom(date,concept,inv,inv2,out,buy,bq) values (""&me.date&"",""&me.concept&"",""&me.inv&"",""&me.inv2&"",""&me.out&"",""&me.buy.text&"",""&me.bq.text&"");")
You need to correctly concatenate your "me." items:DoCmd.RunSQL("insert into custom(date, concept, inv, inv2, out, buy, bq) " &"values ('" & me.date & "', '" & me.concept & ", '" & me.inv2 & "', '" & me.out & "', '" & me.buy & "', '" & me.bq & "')")Ken |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-05-10 : 11:09:03
|
| eadward,1. its good if u post this Access / VBA question in the Access forum (This is "New to SQL server"2. I think in Access the dates should be sorrounded by # (hash) and not by ' (single quote)3. Its easy to debug, if u assign the Query to a string and, when it is running, put a break point, and take the content of the string and run it on the Queries section and see whether it works correctly.Srinika |
 |
|
|
eadward
Starting Member
6 Posts |
Posted - 2006-05-10 : 11:10:26
|
| Thx!It fixed the errors filling the form, it seems that I changed too much the code and could't rebuild that correctly.The other error, that rewrites the records, is still there, I tried with the primary key, it confirmed the problem, some records are rewrited with the new data... |
 |
|
|
eadward
Starting Member
6 Posts |
Posted - 2006-05-10 : 11:12:13
|
Ap, sorry, I didn't know that I'll try to move that |
 |
|
|
|
|
|