Sharon Edmonds (sharonme) wrote in code_wtf,
Sharon Edmonds

MS Access and Visual Basic

Hi. I'm trying to "beef up" one of the Access general templates for use, and I'm running into a problem.

I'm using the "Contacts Management" template, and have added a field "ReferredBy" to the Contacts table. I was wanting to add this as a search item on the "Report Date Range" form, so that I can have a report organized not only by date but grouped by ReferredBy.

I hope this makes sense, I am experienced with Access but not very experienced with Visual Basic. I've done a ton with MySQL, and thought this would be related. I guess I'm wrong... ;-)

I've been able to add the ReferredBy to the Report Date Range form. However, I get an error:

Run-time error '2465': Microsoft Access cannot find the field "|" referred to in your expression.

The VBA for the Report Date Range looks like this:

Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
Me![Referred By] = [ReferredBy]
Me![Beginning Call Date] = Date - Weekday(Date, 2) + 1
Me![Ending Call Date] = Me![Beginning Call Date] + 6
End Sub

Everything works fine when I don't have the "Referredby" line in there, but it does nothing with that item... The way the code is now, it seems circular, but my brain can't figure out how to fix it.

Please help. I am so frustrated and just looking for a little help, even just where I need to go to get help.

Thank you!

x-post in sharonme
  • Post a new comment


    Comments allowed for members only

    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded