I have been building a database for a small animal care facility. I have a report that summarizes information about an animal including basic details of exams, procedures and reports that have been associated with that animal--these are all subforms. Each record in a subform has a button that allows the user to open the full record (form) which I was hoping to do in acPreview mode so they can't accidentially change stuff in the record. The forms themselves are defaulted to open on a new record for data entry purposes, so I am using gotorecord to make sure they open on the record of interest. The code worked fine when I was having the forms open in acNormal, however when I switched to acPreview I get "run-time error '2499'" which says the method can't be applied to an object in design mode, which the forms are not. It still opens the form in preview mode though! As long as you click "end" on the error message you can go ahead and view the record. What am I doing wrong? Do I just need to make reports for these forms and have those open instead? I can certainly do that but am also curious what's going wrong here for the sake of better understanding.
Code in the button:
Private Sub cmdViewFull_Click()
Dim sWhich As String
sWhich = "[ExamAutoID]= " & Me.txtExamAutoID
DoCmd.OpenForm "ExamForm", acPreview, , sWhich
DoCmd.GoToRecord acDataForm, "ExamForm", acGoTo, 1
End Sub
If there's another thread about this I apologize, I looked and couldn't find one. Thank you very much for any guidance!