0
votes

Hello I created a database and I'm trying to make it so that when I click on a field in a report it jumps to a form with the relevant field.

I have a table "tblPagers" a Form "frmPagers" and a report Customer Report

In the table I have a field PagerID and User Name... In my report I want to click on the User Name and have it bring me to my frmPagers on the current record. I'm having problems with my Where Condition.

I have:

If IsNull([User Name]) Then
Beep
End If
If Not IsNull([User Name]) Then
OpenForm
 Form Name frmPagers
 View Form
Where Condition (this is where I have the problem)
Data Mode Edit
Window Mode Dialog

For my where condition I've tried =="[Pager ID]="&[User Name] When I click on a Null User Name it does Beep. However, if I click on a user name I get this error. "Syntax error (missing operator) in query expression '[Pager ID]=Sam Hall'."

1
For clarity the If IsNull([UserName])Then - Shawn

1 Answers

0
votes

Is [Pager ID] a text type field? Does it really store user name text? I suspect no to both.

Try:

If IsNull(Me.[User Name]) Then
    Beep
Else
    DoCmd.OpenForm "frmPagers", , , "[User Name]='" & Me.[User Name] & "'", acFormEdit, acDialog
End If

If must use macro, the WHERE CONDITION would be like:
[User Name] = Reports![Customer Report]![User Name]

Advise no spaces or punctuation/special characters (underscore only exception) in naming convention. Better would be UserName or User_Name, PagerID or Pager_ID.