By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,696 Members | 1,383 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,696 IT Pros & Developers. It's quick & easy.

How to run mysql within a subroutine from the Windows C: prompt

imrosie
100+
P: 222
Hello,

I'm trying to work the bugs out of my app. At compile time I get an error (grey bar covering the 'mysql')when I put the following code in:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdErasePic_Click()
  2. If Not IsNull([imageFile]) Then
  3.     If MsgBox("This image will be permanantly removed, Are you sure?", vbYesNo + vbQuestion) = vbYes Then
  4.     Me!frmimagesubform.Form![imgPicture].Picture = ""
  5.     Me![imageFile] = Null
  6.     SysCmd acSysCmdClearStatus
  7.     DoCmd.SetWarnings False
  8. Dim strSQL As String
  9. 'DELETES the Current Record
  10. mysql = "DELETE * FROM imageInventory Where imageInventory.[imageID] = " & Me![imageID]
  11. DoCmd.strSQL mysql
  12. 'Move the Record Pointer IN some manner
  13. DoCmd.SetWarnings True
  14.     Call Form_Current
  15.     End If
  16.   End If
  17. End Sub
thanks in advance
May 21 '07 #1
Share this Question
Share on Google+
5 Replies

nico5038
Expert 2.5K+
P: 3,072
I've moved your question to the Access forum, so all experts can have a look.

I'm a bit puzzled why you use "mysql", while you define;
dim strSQL

Both won't be needed when you use:

currentdb.execute ("delete * from X where ID=" & myID)

Nic;o)
May 21 '07 #2

imrosie
100+
P: 222
I've moved your question to the Access forum, so all experts can have a look.

I'm a bit puzzled why you use "mysql", while you define;
dim strSQL

Both won't be needed when you use:

currentdb.execute ("delete * from X where ID=" & myID)

Nic;o)
Someone gave this me and I followed it. I'm a newbie. Sorry, what should it be? thanks
May 21 '07 #3

NeoPa
Expert Mod 15k+
P: 31,770
Someone gave this me and I followed it. I'm a newbie. Sorry, what should it be? thanks
Rosie, try to bit a bit more specific showing which error message you got and on which line of the code (by number).
May 23 '07 #4

imrosie
100+
P: 222
Rosie, try to bit a bit more specific showing which error message you got and on which line of the code (by number).

Thanks for your response NeoPa....I finally got it working with help from thescripts, of course. Here's the code that works but has one more issue stated beneath:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdErasePic_Click()
  2. If Not IsNull([imageFile]) Then
  3.     If MsgBox("This image will be permanantly removed, Are you sure?", vbYesNo + vbQuestion) = vbYes Then
  4.     Me!frmimagesubform.Form![imgPicture].Picture = ""
  5.     Me![imageFile] = Null
  6.     SysCmd acSysCmdClearStatus
  7.     DoCmd.SetWarnings False
  8.     Dim mysql As String  'Declare the Variable by assigning SQL String to the variable mysql
  9.  mysql = "DELETE * FROM imageInventory Where imageInventory.imageID = " & Me![imageID]
  10.  'Execute the SQL Statement is next
  11. DoCmd.RunSQL mysql
  12. DoCmd.SetWarnings True
  13.     Call Form_Current
  14.     End If
  15.   End If
  16. End Sub
The other issue is that once the delete occurs, immediately the message #Deleted, pops up in each of the form controls. It causes a problem when (on same form) a user clicks the 'next' control or 'previous'...They get a msg saying 'Type mismatch' error. This error goes away after you close form and reopen (which apparently gets rid of the table deletes, so no error). I've tried using Me.Refresh immediately after the delete in the code, but it doesn't clear it out immediately, I still have to close form and re-open. Any ideas?
May 23 '07 #5

NeoPa
Expert Mod 15k+
P: 31,770
.Refresh won't do it for you. You need .Requery.
The former merely updates the data in records that already were included in your recordset.
May 23 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.