• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1865
  • Last Modified:

DoCmd.GoToRecord acNewRec not working on subform

Hello all,

I have the following code:

    If Me.subform_other.Form.RecordsetClone.RecordCount = 0 Then
        Me.subform_other.SetFocus
        DoCmd.GoToRecord , , acNewRec
    End If

I get a run time error 2105, "You can't go to the specified record."  I think it is because I have the Allow Additions property set to NO for the subform.  I have that function disabled to prevent users from being able to add records on the subform by just rolling the mousewheel.

What is happening here is the main form has a record, but that record does not have an associated record in the subform, so when the form opens some of my code fails that tries to refer to the data on that subform.  The code works if there is a blank record there, so I just thought I would add a record if the system didn't find one on form_current.  

What I need is either:

1.  A way to add a record to the subform if one isn't present on form_current.

2.  A way to disable the mouse wheel functionality, so I can Allow Additions again.  I found very complicated ways of disabling the mouse wheel, so I just decided it was simpler to add a record.

Any suggestions?

Thanks,

G
0
graysoc
Asked:
graysoc
  • 3
  • 2
  • 2
1 Solution
 
peter57rCommented:
Hi graysoc,
www.lebans.com
there is a mousewheel add-in there which is simple to use.

Pete
0
 
puppydogbuddyCommented:
Try this
   If Me.subform_other.Form.RecordsetClone.RecordCount = 0 Then
        Me.subform_other.SetFocus
        Me.subform_other.AllowAdditions = True                     '<<<<<<<<<<<<<<<<
        DoCmd.GoToRecord , , acNewRec
    End If
0
 
puppydogbuddyCommented:
see this link:

             http://support.microsoft.com/?kbid=278379
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
graysocAuthor Commented:
Well,

The allowadditions = true didn't work.  (What I was going to do is allow additions for the one step, then set allow additions back to false.

Also, the MouseHook thing is NOT simple.  I've tried this site before.  Due to how our Access is networked or something, the mousehook.dll file just can't be found by Access.  At least, that is my estimation of why it doesn't work.  I get a "variable not defined" error when the mouse wheel disable code runs...  

Private Sub Form_Load()

Dim blRet As Boolean
blRet = MouseWheelOFF

End Sub

The variable that it is talking about is "MouseWheelOff" which tells me that MouseWheelOff is not getting what it needs from the dll, and Access thinks it is a variable.

Anyway, I'm working on this mousehook thing, to see if I can get it to work.

G
0
 
graysocAuthor Commented:
Thanks Peter, I was able to get the mousehook to work.

G
0
 
peter57rCommented:
I've used Lebans solution a few times.
I haven't run into a problem.
You have to have the dll in same folder as the front-end database that uses it.


Pete
0
 
graysocAuthor Commented:
The problem was that I didn't have the module loaded that defined all of the variables.

G
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now