Francis Rosario
Francis Rosario

Reputation: 13

VBA / Visual Basic. Simple String SQL

I'm creating a Voting System. so it's like this every time A Button1 is pressed + 1 or it will increase the vote in the Access database. I can't find anything in Google.

trx = "update [Table1] SET [Vote] = Vote + 1, (WHERE ID = 1)"

Upvotes: 1

Views: 66

Answers (2)

HaveNoDisplayName
HaveNoDisplayName

Reputation: 8497

Remove comma before Where and brackets around where clause

trx = "update [Table1] SET [Vote] = Vote + 1 WHERE ID = 1"

Upvotes: 1

HansUp
HansUp

Reputation: 97101

Don't include a comma before the WHERE clause. Also you don't need to put the WHERE clause inside parentheses.

Test this as a new query in the Access query designer.

update [Table1] SET [Vote] = Vote + 1 WHERE ID = 1

Fine tune as needed. And once you have it working in the query designer, adapt your VBA code to use that working statement.

Upvotes: 4

Related Questions