473,508 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to correct runtime error 2046?

3 New Member
Question: When I add code to change the record source my sub routine [ATTACHMENTS_DblClick(Cancel As Integer)]
returns a runtime error 2046 Edit hyperlink isn't available now.

The following is provides a little details

I have a form with a subform with the following Sub routine
Which works well, however. I have a like database and I want to use the same forms but just change the record source through code which also works.

Expand|Select|Wrap|Line Numbers
  1. Public Sub ATTACHMENTS_DblClick(Cancel As Integer)
  2.   On Error GoTo error_fileclick 
  3.   If IsNull(Me.ATTACHMENTS.Value) Then
  4.     DoCmd.RunCommand acCmdEditHyperlink
  5.   Else
  6.     DoCmd.RunCommand acCmdOpenHyperlink
  7.   End If
  8. Exit_FileLink:
  9.   Exit Sub
  10. error_fileclick:
  11.   MsgBox "No file has been linked."
  12.   Resume Exit_FileLink
  13. Exit Sub
Feb 5 '11 #1
4 16882
Stewart Ross
2,545 Recognized Expert Moderator Specialist
It's hard to guess from what you've posted, but the most likely explanation I can think of is that the recordsource you have set using VBA code is not updateable - that is, you cannot add or modify records using that recordsource. This would prevent you from being able to run the edit hyperlink command in line 4 above.

It could also be the form's own settings, but I'd assume you would have checked the allow edits and allow additions properties yourself anyway.

You should be able to determine whether or not this is a recordsource issue fairly easily, by opening the recordsource outside of the form itself and attempting to change any field. If you cannot do so the recordsource is not updateable. If you can, then it may be a form property setting.

There is not really enough in what you've posted so far to give any firmer advice until you've checked out the status of your recordsource and form properties.

-Stewart
Feb 5 '11 #2
drd466
3 New Member
Stewart Thanks for the reply.

I'll try brief and clear as possible.
In Access 2007 I have form1 and a Subform2 (which is on a tab control). Form1 and subform2 record source type are dynaset. Form1 default view is single form, while subform2 is datasheet.

All the forms record source are ODBC to Oracle. I have checked the allow additions and edits and they are correct and the recordsource is updateable.

The problem begins when I try to combine the two separate databases into one. All I've done was ODBC to Oracle the like tables, add an unbound text box to the forms which gets its value based from an unbound column on the main menu thats always open.

The forms recordsource is changed by the following code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. 'FAPC
  3.  If Me.BusinessUnit.Value = "FAPC" Then
  4.     Me.RecordSource = "FAPC_WO_CODE_DATA"
  5.  End If
  6.  
  7. 'FTOL
  8.  If Me.BusinessUnit.Value = "FTOL" Then
  9.     Me.RecordSource = "FTOL_WO_CODE_DATA"
  10.  End If
  11. End Sub
As mentioned subform2 is on a tab control. On another tab of the same control is subform3 which also runs off the Public subroutine above on the original post and works.

I've noticed on the first line of subform2 (datasheet view) the code works. When I double click on subsequent lines in the datasheet view the runtime error 2046 appears.

I hope this provides more clarity.
Feb 6 '11 #3
Stewart Ross
2,545 Recognized Expert Moderator Specialist
The source of the problem is not at all obvious. One or two questions arise from what you've posted, though; the recordsource change is in the form's Current event, which is fired whenever the form moves from record to record. You will be changing the recordsource of the main form every time you move from one record to the next; is this intentional?

If you want to change recordsource according to the value of, say, an unbound combo on a form it is more usual to do so using the AfterUpdate event of the combo concerned to trigger the change, not on the Current event of the form. If the control you are testing, BusinessUnit, is bound to the recordsource itself then I think you could end up in difficult territory of recordsource changes occurring when you don't expect them to, which in turn affects any subforms related to the main recordsource.

Speaking of which, do the same field parent/child relationships apply from the main to the subform when you've change the recordsource?

Another possibility raised by what you've posted is the ODBC refresh interval set for the database, which you will find under Access Options, Advanced. This is set to 1500ms by default; you may wish to reduce this value to see if this may have some contribution to what is going on.

More questions than answers I guess.

One way to approach the systematic elimination of possibilities in the meantime is to verify that the updates work or do not work for both recordsources set WITHOUT any dynamic changes to the form's recordsource. In other words simply comment out the recordsource change in Form Current, and try out the form with both recordset choices set by yourself manually to rule out problems with each in turn.

-Stewart
Feb 6 '11 #4
drd466
3 New Member
Stewart,
Thanks for staying with me. I was away for a few days and the reason for a slow reply.

And you're right I believe the after update event is better. I push the record source to my FormA prior to its opening through an on click event from the main menu, which actually is a submenu of the main menu.

However, FormA has several subforms (on a tab control) in which the recordsource is set on each of the subforms current event. And each subform has the unbound BusinessUnit control which is set on the same on click event that opens FormA.

Is it be better to set the record source for each subform on the same on click event that opens FormA just as I do with BuisnessUnit?

My thinking, this will eliminate the on current event when moving from record to record.

I tried the after update event of the unbound BuisnessUnit control (hidden), but since it is set when FormA is opened there is no after update event that triggers.

The BusinessUnit is an unbound control.

Each tab, on the tab control is linked to a different table and therefore the parent/child relationships changes but the parent (master) is the same for each tab. The child is the only change.

I haven't had a chance to verify the refresh interval of the ODBC but 1500ms sounds correct.

As suggested, I commented out the on current event of the subform and manually set the recordsource and the Public Sub ATTACHMENTS_DblClick event code works fine.

If you think it would help I could post the record source used when the form is opened.

Thanks
David
Feb 10 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
46571
by: Dario | last post by:
This is a technical C++ post regarding the Microsoft runtime error R6025 Pure Virtual Function Call that sometime occurs in programs compiled with Microsoft Visual C++ 6.0. Please consider the...
2
3293
by: Nicolae Fieraru | last post by:
Hi All, I have a table in the database and a Word document saved on the hard disk. I want to mailmerge the content of the table into the word document, all done in vba. Any examples? I...
7
1862
by: Charlie Brookhart | last post by:
I have a program (posted below) that is supposed to take liters, which is the user input, and convert it to pints and gallons. The pints and gallons are displayed in a read only textbox. I don't...
7
37995
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement...
0
3172
by: rajkalacbe | last post by:
I am running a visual basic executable program through Forms4.5 of D2K using Forms menu options.. When I Invoke this form in the server where I have the database installed, I do not have any...
4
2521
by: katzc | last post by:
Microsoft Visual C++ Runtime Library Runtime Error! Program:C:\PROGRA~1\Aveo\Attune\bin\Attune_DI.exe abnormal program termination I get this error message mostly when I'm trying to get onto...
6
8737
by: tony.abbitt | last post by:
I have recently installed Office 2007 (SP1) retaining the previous installation of Office 2003. I have converted an Access 2003 database to Access 2007. The database contains the VBA code...
6
13576
by: OldBirdman | last post by:
I've spent all day on this, and can't see what I'm doing wrong. I've Googled and all I find have the same mistake, using .Text when they should use .Value. In this case, .Text is correct. ...
7
3155
by: JKoyis | last post by:
I'm having some trouble with the code on this form - it's intended to increment the grades of all the students in the database. If I open the form in design view and then switch to normal view it...
16
19081
by: rudivs | last post by:
I would like to do data validation in the BeforeUpdate procedure, but Access gives me a runtime error when I try to do this: An example of what I am trying to do is as follows: Private Sub...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.