Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Only One Record per Form 1

Status
Not open for further replies.

Mike555

Technical User
Feb 21, 2003
1,200
US
My form contains a drop-down box (code is below) which lists primary keys (sequential numbers) of records located in another form named RequestForm. When a user selects a number from the list, the user is taken into RequestForm to that record. (RequestForm is filtered to just show that record)

The problem is that although RequestForm is filtered to take the user to the specific record they select, the users are still able to move one record forward to a blank record. For example - They go into a specific record, but then they move their mouse wheel which takes them to the next record. Is there a way to filter RequestForm so that only the selected record (and not the selected record + one blank record) are available upon entering it. Thanks!



Private Sub goto1_AfterUpdate()
On Error GoTo Err_goto1_Click

Dim stLinkCriteria As String

stLinkCriteria = "[ID]= " & Me![goto1] & ""
DoCmd.OpenForm "RequestForm", , , stLinkCriteria

Exit_goto1_Click:
Exit Sub

Err_goto1_Click:
MsgBox Err.Description
Resume Exit_goto1_Click

End Sub
 
Mike,

Although I'm sure there are many other ways of doing it, one way I have done this in the past is to open a new form based on a query of the table.

For the criteria put [Forms]![OriginalForm]![goto1].

This query will have just this one record so there will be none to scroll to.

This is how I've handled a similar situation in the past.
 
Hi!

If you set the AllowAdditions property to no in the RequestForm then the user will not be allowed to scroll to a blank record.

hth


Jeff Bridgham
bridgham@purdue.edu
 
Can the AllowAdditions property be set to no when RequestForm is accessed through the dropdown box, and be set to yes when the form is opened regularly?

Some users open the form directly to add records, so I only want to set the AllowAdditions = no for users accessing the form through the drop-down box.

Thank you both for your help!
 
Hi!

One way I can think of off the top of my head is to use the DataMode in the OpenForm Method:

DoCmd.OpenForm "RequestForm", , , , acFormReadOnly

I assume you are also applying a filter here as well but, if you are not familiar with the openform method, you can look it up in the help. If you want the user to be able change the record they are viewing then use the OpenArgs of the OpenForm Method:

DoCmd.OpenForm "RequestForm", , , , , , "NoAdditions"

Then in the Form_Open procedure use:

If Me.OpenArgs = "NoAdditions" Then
Me.AllowAdditions = False
Else
Me.AllowAdditions = True
End If

Obviously, this can give you a lot of flexibility in setting the form properties.

hth


Jeff Bridgham
bridgham@purdue.edu
 
Awesome! This is what I needed. Here is my syntax: DoCmd.OpenForm "RequestForm", , , stLinkCriteria, , , "NoAdditions"

Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top