473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADO new record #Error why??

Hello Everyone

I have a main form (frmNewOrder) and a sub form (SubOrderBenefi ciary).
On the main form I have a button which sends the Subform
(SubOrderBenefi ciary) to a newrecord. Everything works fine expect that
when I press the button, the controls on the subform display an #Error
for a fraction of a second when changing from the current record on the
subform to the new record and theneverything works fine.

Does anyone knows how can I prevent this as it does not look
professional?

The code Im using is as follows:

Private Sub cmdNewBene_Clic k()
On Error GoTo Err_cmdNewBene_ Click

Dim cn As ADODB.Connectio n
Dim rs As ADODB.Recordset

Set cn = CurrentProject. AccessConnectio n
Set rs = New ADODB.Recordset
Set SubBen = Me.SubOrderBene ficiary.Form

With rs
Set .ActiveConnecti on = cn
.Source = "SELECT * FROM tblBeneficiary WHERE BeneficiaryID =
''"
.LockType = adLockOptimisti c
.CursorType = adOpenKeyset
.Open
End With

Set SubBen.Recordse t = rs
Set rs = Nothing
Set cn = Nothing
Me.SubOrderBene ficiary.SetFocu s

Exit_cmdNewBene _Click:
Exit Sub

Err_cmdNewBene_ Click:
MsgBox "Your request could not be processed. Err 14 - " &
Err.Description & Err.Number, vbCritical, "Error"
Resume Exit_cmdNewBene _Click
End Sub
Any comments and possible solution would help me a lot.

Thanks in advanced.
GAVO.

Dec 1 '05
20 2273
No, no one has actually bought anything from me on this news group.
So your doubt is well-justified.
Of course, I have nothing for sale, so this may not be so surprising.

Dec 1 '05 #11
GAVO-UK wrote:
Has anyone actually bought anything from you on this news group? I
really doubt it.


Many, many of us have benefitted from Lyle's posts here over the years.

Basically, what he's saying is you have written code needlessly and what
you describe in your post as what you're trying to do is already done by
Access. So you're struggling (needlessly) to code something that Access
already does for you.

Just make the recordsource of the sub form SubOrderBenefic iary:

SELECT * FROM tblBeneficiary WHERE BeneficiaryID =
forms!frmNewOrd er!SomeField

When you move from record to record in frmNewOrder, the display in
SubOrderBenefic iary will change.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Dec 2 '05 #12
rkc
GAVO-UK wrote:
Has anyone actually bought anything from you on this news group? I
really doubt it.


I've stolen a thing or two from him.
Dec 2 '05 #13
If my post offended anyone, Im sorry about that, its just that this
other day this guy offered my to pay him to solve my problem in this
news group and this other time some one else offered to sell me a pice
of code/App that did what i was looking for.

I read you post in hurry and missed the point completely.
Thanks anyway for you trying to help

GAVO

Dec 2 '05 #14
If my post offended anyone, Im sorry about that, its just that this
other day this guy offered my to pay him to solve my problem in this
news group and this other time some one else offered to sell me a pice
of code/App that did what i was looking for.
I read you post in hurry and missed the point completely.
Thanks anyway for you trying to help

-----------------------------

Tim

I know that Access does something like that, my problem is that the
subform which I'm talking about is not linked to the main form but to
another sub form, let me explain.

This is an ADP application with an SQL back end, which will be accessed
using the internet (ADSL or Dial Up). I am using unbound forms and
subforms and setting their recordset from code.

The main form (frmNewOrder - Unbound) has two subforms SubForm1
(subNewOrderCus tomer - being the main subform) and SubForm2
(SubNewOrderBen eficary - Linked to Subform 1). What I'm trying to do
is; call a code using a button from the Main form which would send the
just the subform 2 to a new record and the SubForm 1 remain in its
current record.

Maybe I'm struggling in something which is done easily, but then as I
already said, my code is working its just that it display an #Error for
a fraction of a second in the controls of SubForm 2 before sending it
to a new record.

Jaime.

Dec 2 '05 #15
TC
Maybe try this:

1. Unbind all of the form controls from the datasource;
2. Do whatever it is that causes the controls to say #Error;
3. Rebind the controls.

This would only take a few lines of code & could work quite well IMO.

HTH,
TC

Dec 2 '05 #16
"TC" <aa**********@y ahoo.com> wrote
1. Unbind all of the form controls from the datasource;
2. Do whatever it is that causes the controls to say #Error;
3. Rebind the controls.


Dim c As Boolean
c = (Me.RecordsetCl one.RecordCount > 0)

Me!btnSortByNam e.Enabled = c
Me!btnSortByLev el.Enabled = c
If c Then
Me!txtName.Cont rolSource = "off_name"
Me!txtLevel.Con trolSource = "cs_level"
Else
Me!txtName.Cont rolSource = vbNullString
Me!txtLevel.Con trolSource = vbNullString
End If
--
Darryl Kerkeslager

Dec 2 '05 #17
TC
Um, sorta. I had more like this in mind:

' unbind the controls.
dim ctl as control
for each ctl in me.controls
with ctl
if .controlsource< >"" then
.tag = .controlsource
.controlsource= ""
endif
end with
next
' now do the thing which causes #error to occur.
' ( do thing ... do thing )
' rebind the controls.
for each ctl in me.controls
with ctl
if .tag<>"" then
.contrtolsource = .tag
.tag=""
endif
end with
next

That code is a bit rough because it assumes that the tag properties are
blank to begin with, and that they are not already used for other
purposes. But it would be easy to store the controlsource values
somehow else, eg. in a collection.

HTH,
TC

Dec 2 '05 #18
TC.

I use a similar code to check for nulls, therefore my tags are already
in use. What other way can I implement you code and use an alternative
to tags, I know you mentioned a possible solution but ! have no idea
how to do it! any guidelines?

Thanks
GAVO

Dec 2 '05 #19
TC
Try this (untested):

dim cs as collection
set cs = new collection

' unbind the controls.
dim ctl as control
for each ctl in me.controls
with ctl
if .controlsource< >"" then
cs.add .name & "|" & .controlsource, .name ' item, key.
.controlsource= ""
endif
end with
next

' now do the thing which causes #error to occur.
' ( do thing ... do thing )

' rebind the controls.
dim v as variant, n as integer
for each v in cs
n = instr(v, "|")
me.controls(lef t$(v,n-1)).controlsour ce = mid$(v, n+1)
next
set cs = nothing

HTH,
TC

Dec 2 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
44119
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr scott/tiger@common control=/full_path/test.ctl log=/full_path/adhoc/test.log SQL*Loader: Release 9.2.0.1.0 - Production on Tue Sep 2 10:49:27 2003 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
15
4667
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any field to start. If I edit that field and then click on the new record button in the navigation buttons, the form goes to a new record and each field has the default value of the previous record. If I put the focus in any field to start, edit that...
2
15424
by: RC | last post by:
I am getting the following error message. "Write Conflict this record has been changed by another user since you started edting it. If you save the record, you will overwrite the changes...." I have an Access 2002 database running on a single PC, the front and backend have not been separated yet. I have a form where I use a text box to jump from record to record. The form has about 12 bound text boxes on it. The table that is the...
3
26289
by: hebandgene | last post by:
When I delete a record in a subform I get the warning that I'm about to delete a record, followed by an error "No current record." When I click OK obviously the record is deleted and it goes to the first record (as I've coded it to do) or it shows me a blank record if the deleted record was the only one. So, what I'd like to do is bypass that 'No current record' altogether to avoid user confusion. Is there any way to code it out...
20
10685
by: MS | last post by:
Access 97 I want to requery the data being displayed on a form, then I want to return to the record I was in. Why doesn't this code work? Private Sub CmdRefsh_Click()
8
12120
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
1
5421
by: Scott269 | last post by:
So I've got an old MS Works database I imported into Access. I needed a primary key so I created a record number field that was just the record number I manually inserted when I entered it in the database so I could sort the records by the date at which they were entered. Well now I've deleted some of those records so its of course causing gaps in the records. The record number in Access no longer matches my record number that I...
4
7854
by: Susan Bricker | last post by:
I have a command button on a form that is supposed to Delete the record being displayed. The record is displayed one to a form. The form is not a Pop-Up nor is it Modal. Tracing the btnDelete event routine shows that AllowDeletions is TRUE. When the Delete button is clicked (without TRACE ON), I get a 'beep', the recordselector (vertical bar on left of form) gets dark in color, but the record is not deleted. Also, there is no error...
8
2430
by: Tom | last post by:
Hi I have an aspx page which has javascript to configure xmldata. I added breakpoint to the button method. When I click submit button, it did not go to those breakpoint and show the following error System.Web.HttpRequestValidationException (0x80004005) Detect the potential danger of Request.Form value from client side (idHidxml="<recordset><record><...") System.Web.HttpRequest.ValidateString(String s, String valueName, String...
5
3189
by: prakashwadhwani | last post by:
The Delete Event/Proc & "Save_Fields_In_Form_Header" Event/Proc in my form were working perfectly. However, after I added a call to the "Save_Fields_In_Form_Header" Event/Proc in the "Current" Event of my form, and I now try to Delete a record, I get ... Run-Time Error 3218 - Could not Update; Currently Locked. My Access application then effectively freezes forcing me to shut Access down & re-start. The record DOES get deleted...
0
9715
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.