Group:  Microsoft Access ยป microsoft.public.access.adp.sqlserver
Thread: Using VBA in an ADP to generate an ID value

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Using VBA in an ADP to generate an ID value
imani_technology_spam[ at ]yahoo.com 22.09.2006 21:34:58
The table in the database has a field called LabID. That field is an
integer and consists of the year plus a counter. For example, the
first record of 2006 would be "20060001," the second record of 2006
would be "20060002" and so on.

Originally, I tried to create an Insert trigger that could generate the
ID value when a new record is inserted. An MVP in another forum was
kind enough to help me with this trigger and it worked flawlessly.
However, the problem is the Access ADP. Basically, the trigger and and
the bound form in the ADP did not get along, and an error message
occurred every time an attempt was made to insert a new row.

Now I'm looking at a new approach. I would like to generate the value
described in the first paragraph, but in the bound form itself instead
of using a trigger. I'm sure this would require a VBA solution, but my
VBA isn't as strong as my SQL. Can anyone help me achieve this goal
listed in the first paragraph using VBA in the form?

Re: Using VBA in an ADP to generate an ID value
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)> 24.09.2006 02:09:06
Do you want to use or is it necessary to use this LabID as the primary key
for the table or not?

If it's not necessary, then all you have to do is to add an identity field
to be used as the primary key and make ADP happy and use your present
trigger to create the new value. It will also be better if you set the
ResyncCommand and the UniqueTable properties but not necessary.

If you want to set this value in VBA code, the best place in my opinion
would be probably to use the OnBeforeUpdate event of the form.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


<imani_technology_spam[ at ]yahoo.com> wrote in message
news:1158960898.162750.217790[ at ]i42g2000cwa.googlegroups.com...
[Quoted Text]
> The table in the database has a field called LabID. That field is an
> integer and consists of the year plus a counter. For example, the
> first record of 2006 would be "20060001," the second record of 2006
> would be "20060002" and so on.
>
> Originally, I tried to create an Insert trigger that could generate the
> ID value when a new record is inserted. An MVP in another forum was
> kind enough to help me with this trigger and it worked flawlessly.
> However, the problem is the Access ADP. Basically, the trigger and and
> the bound form in the ADP did not get along, and an error message
> occurred every time an attempt was made to insert a new row.
>
> Now I'm looking at a new approach. I would like to generate the value
> described in the first paragraph, but in the bound form itself instead
> of using a trigger. I'm sure this would require a VBA solution, but my
> VBA isn't as strong as my SQL. Can anyone help me achieve this goal
> listed in the first paragraph using VBA in the form?
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net