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

Compile error - Invalid qualifier

P: 7
My form (frmERLogs) for this project (ER Log Book) has a combo box (cboMedicalRecordNumber) that I want to be able to double click on to bring up a new form (frmPatientInformation) when a name is not already in the list. When I double click on that combo box, I get this message 'Compile error - Invalid qualifier'. Below is the coding for the double click event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboMedicalRecordNumber_DblClick(Cancel As Integer)
  2.  
  3. Dim rs As DAO.Recordset
  4. Dim strWhere As String
  5. Const frmPatientInformation = "Patients"
  6.  
  7. 'Set up to search for the current customer.
  8. If Not IsNull(Me.cboMedicalRecordNumber) Then
  9.     strWhere = "cboMedicalRecordNumber = """ & Me.cboMedicalRecordNumber & """"
  10. End If
  11.  
  12. 'Open the editing form.
  13. If Not frmPatientInformation.AllForms(frmPatientInformation).IsLoaded Then  'above statement emboldened before code tags added
  14.     DoCmd.OpenForm frmPatientInformaion
  15. End If
  16. With Forms(frmPatientInformation)
  17.  
  18. 'Save any edits in progress, and make it the active form.
  19. If .Dirty Then .Dirty = False
  20. .SetFocus
  21. If strWhere <> vbNullString Then
  22. 'Find the record matching the combo.
  23.     Set rs = .RecordsetClone
  24.     rs.FindFirst strWhere
  25.     If Not rs.NoMatch Then
  26.     .Bookmark = rs.Bookmark
  27. End If
  28. Else
  29.     'Combo was blank, so go to new record.
  30.     RunCommand acCmdRecordsGoToNew
  31. End If
  32. End With
  33. Set rs = Nothing
  34.  
  35.  
  36. End Sub
The sentence in bold is the part that shows as being a problem. The part 'frmPatientInformation' in front of AllForms(frmPatientInformation) is highlighted. Is it supposed to be the project name in front of 'AllForms(frmPatientInformation)? And if so, how is it coded. Nothing I have tried putting in there has changed the error that comes up.

I am working in Access 2003

Thanks for any help you can provide.
Mar 14 '08 #1
Share this Question
Share on Google+
4 Replies


Expert Mod 2.5K+
P: 2,545
Hi. The reference to the IsLoaded property is incorrect, as you will see if you look at the IsLoaded function provided in the MS Northwind database. The initial reference is not to the form but to the CurrentProject property. Also, the name of the form needs to be passed as either a string variable or as a string literal. String literals should be in quotes. These were missing in your code.

Your code has other problems as well, not least with the IF...THEN structure which is out of sync in the later part of your code. It is not good practice to mix true IF..THEN..ELSE constructs with single-line IFs, as this makes it difficult to work out the logic of your code.

I append a corrected version below, with the in-line IFs replaced and an ENDIF swapped at the bookmark end of the code to correct a sequencing error.

-Stewart
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboMedicalRecordNumber_DblClick(Cancel As Integer)
  2.  
  3. Dim rs As DAO.Recordset
  4. Dim strWhere As String
  5. Const frmPatientInformation = "Patients"
  6.  
  7. 'Set up to search for the current customer.
  8. If Not IsNull(Me.cboMedicalRecordNumber) Then
  9.     strWhere = "cboMedicalRecordNumber = """ &_
  10.     Me.cboMedicalRecordNumber & """"
  11. End If
  12.  
  13. 'Open the editing form.
  14. IF Not CurrentProject.AllForms("frmPatientInformation").IsLoaded THEN 
  15.     DoCmd.OpenForm frmPatientInformaion
  16. End If
  17. With Forms(frmPatientInformation)
  18.  
  19.     'Save any edits in progress, and make it the active form.
  20.     IF .Dirty Then
  21.         .Dirty = False
  22.     END IF
  23.     .SetFocus
  24.     IF strWhere <> vbNullString THEN
  25.     'Find the record matching the combo.
  26.     Set rs = .RecordsetClone
  27.         rs.FindFirst strWhere
  28.         IF Not rs.NoMatch THEN
  29.             .Bookmark = rs.Bookmark
  30.         Else
  31.             'Combo was blank, so go to new record.
  32.         RunCommand acCmdRecordsGoToNew
  33.         END IF
  34.     END IF
  35. End With
  36. Set rs = Nothing
  37. End Sub
Mar 14 '08 #2

P: 7
Thanks for your help. I did alter it and although it does not show the same error, it does highlight the same line. When I put my cursor over it now, it shows this beneath it:
Current Project...=<The expression you entered refers to an object that ...

I couldn't find a way to view the rest of that statement - if there was more to it. Do you know what that means?

Thanks also for pointing out some of the other errors.
Mar 14 '08 #3

P: 7
I did find out where to do the step through and find out the whole error message which says the form is either closed or doesn't exist. I know the spelling of the form is correct, so I am trying to find where else it might be breaking.
Mar 15 '08 #4

Expert Mod 2.5K+
P: 2,545
I did find out where to do the step through and find out the whole error message which says the form is either closed or doesn't exist. I know the spelling of the form is correct, so I am trying to find where else it might be breaking.
Hi. Have you enclosed the form name in quotes in the IsLoaded expression? If not this alone will give rise to an error. There are also at leaset two subsequent references to the form name in your code which need to be in quotes - to pass the form name as a sytring literal to the properties concerned.
Expand|Select|Wrap|Line Numbers
  1. IF Not CurrentProject.AllForms("frmPatientInformation").IsLoaded THEN 
  2.     DoCmd.OpenForm "frmPatientInformaion"
  3. End If
  4. With Forms("frmPatientInformation")
-Stewart
Mar 16 '08 #5

Post your reply

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