[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

DoCmd.GoToRecord  acNewRec not working on subform

Posted on 2006-05-03
7
Medium Priority
?
1,746 Views
Last Modified: 2008-01-09
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
Comment
Question by:graysoc
  • 3
  • 2
  • 2
7 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 16595922
Hi graysoc,
www.lebans.com
there is a mousewheel add-in there which is simple to use.

Pete
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16596086
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
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 16596427
see this link:

             http://support.microsoft.com/?kbid=278379
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:graysoc
ID: 16596431
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
 
LVL 1

Author Comment

by:graysoc
ID: 16596480
Thanks Peter, I was able to get the mousehook to work.

G
0
 
LVL 77

Expert Comment

by:peter57r
ID: 16596490
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
 
LVL 1

Author Comment

by:graysoc
ID: 16596504
The problem was that I didn't have the module loaded that defined all of the variables.

G
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question