How to reset GUID field with VBA

  • Thread starter Thread starter Douglas J. Steele
  • Start date Start date
D

Douglas J. Steele

It's possible that you may not be able to change it. For example, you can't
change Autonumber values.
 
Hello NG,

i have follow issue analog to KB295219:

Environment
SQL-Server 2k tables linked into Access2003SP3 database (DSN-less).
( ! prior version ACC97 stay installed on my machine, must support old
versions ;-( !)

Issue:
A product record has related category stored in a uniqueidentifier typed
field
'Category'coded from 'Categories'- table.
This all displayed in a form.


My question:
How can i reset product category per VBA code ? ( Sub
btnCategoryReset.OnClick)

Me!Category=NULL

statement does throw error 3162 'You tried to assign NULL value
to a variable that is not Variant data type'.
The same for

My!Category.value=NULL.

A vartype (My!Category.value) call returns 8 - also a string.

Me!Category.value=vbNullString

stay throws 3162...

What is wrong ?

Thanx for help and any hints.
Hermann
 
I am not sure from your description ...

It sounds like the tblProducts has a Field [Category]
which is a *ForeignKey*, NOT a PK/GUID, linking to the
tblCategories to classify the Product into a particular
category.

If this is the case, you will need to check the design of
the tblProduct (in SQL Server) to see if Null is allowed
for the ForeignKey Field [Category] and whether you have
set R.I. on the relationship between tblCategories and
tblProducts.

HTH
Van T. Dinh
MVP (Access)
 
Hello
Van T. Dinh said:
I am not sure from your description ...

It sounds like the tblProducts has a Field [Category]
which is a *ForeignKey*, NOT a PK/GUID, linking to the
tblCategories to classify the Product into a particular
category.

Yes, it is a FK.
If this is the case, you will need to check the design of
the tblProduct (in SQL Server) to see if Null is allowed
for the ForeignKey Field [Category] and whether you have
set R.I. on the relationship between tblCategories and
tblProducts.

Bingo that is it, Null-Values was not allowed...

I'm wondering that a VBA and not a SQL ODBC error was throwed.

Thanx for your help.

Hermann
 
Back
Top