acGoTo Record



I have a form that indicates if someone's email address is missing. If the
indicator pops up that says it is missing, then the user can click on the
word email and a second form pops up with a box to enter their email address.
The problem is that I'm having problems calling the appropriate record to
ender the address since the Unique ID has gaps in it where records were added
and deleted. The code below is what I use, but since acGoTo is an offset
function, it sends it to the wrong record. Is there a way to figure out what
it's position and not it's ID? Would make a great deal of use!

CurRec = DLookup("[ID]", "Members", "[ID] = " & Me.[FullName])
stDocName = "Email Entry"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acGoTo, CurRec

Thank you in advance, would love some help.



Steve Schapel


If I understand you correctly, it seems to me that you can replace those
4 lines of code with this...
DoCmd.OpenForm "Email Entry", , , "[ID]=" & Me.FullName


Jan 18, 2014
Reaction score
'This works for me.
Public pGoToRecord As AcRecord

'This is a command button on the main form. It.opens a dialog box when the user clicks the this button.

Private Sub cmdOpenDialog_Click()
DoCmd.OpenForm "Dialog", acNormal, , , , acDialog
DoCmd.GoToRecord acDataForm, "Contact Detail", acGoTo, pGoToRecord
End Sub

'This is a dialog box with a list box on it with ID and Company_Name in the list box. The ID is 0 width so only Company name is displayed.. When the user to selects one of the lines in the list box, the ID is saved in the public variable pGoToRecord. The main form uses this public variable to position itself on that record. Using a variable of Type acRecord solves the problem of argument of wrong type.

Private Sub lstCompany_Click()
pGoToRecord = Me.lstCompany.Value
Form_Dialog.Visible = False
End Sub

'Let me know it this works for you.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question