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

Runtime Error 2001 and " you cancel the previous operation"

P: 75
I am getting a yellowish block on Refresh statement under Medication_Name_AfterUpdate, and If i take it out it comes to the End sub... dont know what is goign on?

This is what I have under Text52
Expand|Select|Wrap|Line Numbers
  1. =DLookUp("Concentration","medquery")
  2.  
and under Text54
Expand|Select|Wrap|Line Numbers
  1. =DLookUp("Units","medquery")
  2.  
On my form I have Concentration and Units text box. The value should be saved in my Main Table from Text52 and Text54, but it should apperas under Concentration and Units. I am keeping Text52 and Text54 not visible? any idea?

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Medication_Name_AfterUpdate()
  3. Concentration = Text52
  4. Units = Text54
  5. Refresh
  6. End Sub
  7.  
  8. Private Sub Medication_Name_Change()
  9.  
  10. 'DoCmd.OpenQuery "medquery"
  11.   Me!Concentration.Requery
  12.     Concentration = Text52
  13.     Units = Text54
  14.     Refresh
  15.    End Sub
  16.  
  17. Private Sub Text52_Change()
  18. Refresh
  19. Concentration = Text52
  20. Units = Text54
  21. Refresh
  22.  
  23. End Sub
  24.  
Jun 28 '07 #1
Share this Question
Share on Google+
8 Replies


P: 75
I am sure I have posted in the right area. so, how come I am not getting any reply.
Jun 29 '07 #2

puppydogbuddy
Expert 100+
P: 1,923
I am sure I have posted in the right area. so, how come I am not getting any reply.

you have not provided enough info. You need to provide the sql of medquery and the structure of your table(s).

but, as a start, try changing this wherever used:
Concentration = Text52
Units = Text54

to this:
Concentration.Value = Me!Text52
Units.Value = Me!Text54
Jun 29 '07 #3

puppydogbuddy
Expert 100+
P: 1,923
also:
change this:
Refresh

to: Me.Requery
Jun 29 '07 #4

P: 75
also:
change this:
Refresh

to: Me.Requery
Thanks for your reply. Nice of you.
I have tried exactly what you wrote in your first reply. It worked fine but it wont let refresh. Lets say If i pick one medication it will work fine and it will also save in the main table, but If I chose another medication name, the medication will change but the concentration and the Unit will not change, it will stay the same.
I have put the Me.Requery but after that I am still getting the same error.

Thanks.
Jun 29 '07 #5

puppydogbuddy
Expert 100+
P: 1,923
Thanks for your reply. Nice of you.
I have tried exactly what you wrote in your first reply. It worked fine but it wont let refresh. Lets say If i pick one medication it will work fine and it will also save in the main table, but If I chose another medication name, the medication will change but the concentration and the Unit will not change, it will stay the same.
I have put the Me.Requery but after that I am still getting the same error.

Thanks.
You still haven't provided the sql of medquery, so I am guessing, but try:
=DLookUp("Concentration","medquery", "[MedicationName] = '" & Forms!YourForm!MedicationName & "'")

=DLookUp("Units","medquery", "[MedicationName] = '" & Forms!YourForm!MedicationName & "'")
Jun 29 '07 #6

P: 75
You still haven't provided the sql of medquery, so I am guessing, but try:
=DLookUp("Concentration","medquery", "[MedicationName] = '" & Forms!YourForm!MedicationName & "'")

=DLookUp("Units","medquery", "[MedicationName] = '" & Forms!YourForm!MedicationName & "'")
ohh sorry here it is.

Expand|Select|Wrap|Line Numbers
  1. SELECT Medications.Concentration, Medications.Units
  2. FROM Medications
  3. WHERE (((Medications.Medication_Name)=[Forms]![frmMain]![Medication_Name]));
  4.  
Jun 29 '07 #7

puppydogbuddy
Expert 100+
P: 1,923
ohh sorry here it is.

Expand|Select|Wrap|Line Numbers
  1. SELECT Medications.Concentration, Medications.Units
  2. FROM Medications
  3. WHERE (((Medications.Medication_Name)=[Forms]![frmMain]![Medication_Name]));
  4.  
Ok, here is what you need to do..

1. make your textboxes visible for testing purposes

2. change medquery to the following:
SELECT Medication_Name, Concentration, Units FROM Medications;

3. change the Dlookups as shown:

=DLookUp("Concentration","medquery", "[Medication_Name] = '" & Forms!YourForm!Medication_Name & "'")

=DLookUp("Units","medquery", "[Medication_Name] = '" & Forms!YourForm!Medication_Name & "'")
Jun 29 '07 #8

P: 75
It worked..Thanks alot.
Jun 29 '07 #9

Post your reply

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