Topics Search

Reset a text field to NULL with VBA code

Reset a text field to NULL with VBA code
Views: 224
I have a database which contains a text field called TransactionDescription. I want to reset this field back to a NULL (ie: blank value) on all records in my table.
Sponsored Links:

Similar posts...

 

VBA Code - Replacing Null Values with 0

VBA Code - Replacing Null Values with 0 Icon
I'm a struggling to come up with a custom function that replaces Null values in a table with Zero.

My table in its basic form has two fields.
Field A: Client
Field B: Quantity

The data is pulled from elsewhere in the database, but when it extracts it will have the client, and quantities. but some clients will have a Null quantity. e.g. below:
 

VBA to clear or reset text fields from a click of a command button

VBA to clear or reset text fields from a click of a command button Icon
Is it possible to add vba code to a command button that when clicked the event will clear existing data or reset data, so when the user is on the form, the previous data entereddoesn't display? if so how can this be done?
 

Text to Currency formatting issue VBA

Text to Currency formatting issue VBA Icon
I have code that creates a new table with designated fields(see below). The rstDest table has Currency values for each month and the rstSource table has text values. I need to change these text values to currency and am running into some issues.

One thing is yes, the text field can be null, there won't always be a value.

I have tried this:
 

Problem with IIf

Problem with IIf Icon
I use the following in a field in my report.
IIf(IsNull([X]), ,[Y])
where the
X field is defined as text, and populated with either null (no entry) or a text string.
Y field is defined as number and carries some number value.
Both X and Y are table entries.
Problem I have is that when X is null, I get the desired empty space, but when X is not null, I get #Error.
 

Executing MySQL Statement

Executing MySQL Statement Icon
I have a variable that contains a perfectly acceptable MySQL statement (as in, I can copy it into mysql directly and it works) yet when I run it through CurrentDb.Execute VariableName I get "Too few parameters. Expected 1."

[CODE]

Which the makes

INSERT INTO ticketchanges VALUES (NULL,46,DEFAULT,'few af ae a',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,2);

The only thing I can think of is that I'm not declaring the column names because as you can see by the code, it's rather dynamic. So.
 

Using an expression to add a record based on a field containing any text

Using an expression to add a record based on a field containing any text Icon
In Access 2002 I am attempting to add text to Field 2 if Field 1 contains any text at all using a query expression.

I have tried innumerable combinations of IIf, Is Not Null, Like using wildcards etc. For example IIf([Composer] is not null), "CA" (Suggested on an MS site) however I can't seem to find the right expression.
 

Bookmarks and Null values

Bookmarks and Null values Icon
I have a section of my form that may contain no data what so ever and therefore I need to have a code that if theres no data a field to put a space and if there is a value to put the value in.

Heres the code im using and yet im getting Error 94 Invalid use of null

PHP Code:
If[MEBondingConLocation1]=NullThen.ActiveDocument.Bookmarks("Text37").Select.Selection.Text=""Else
.ActiveDocument.Bookmarks("Text37").Select.Selection.Text=Me.M_EBondingConLocation
 

update field once upon opening, but not the 2nd time the record is opened

update field once upon opening, but not the 2nd time the record is opened Icon
I currently have a form that has a date/time field that is automatically updated when the form is loaded.

However, when this form is closed and reopened again, the field re-updates. How can I prevent this field from re-updating. Is there some sort of VBA code that I can enter that does thiswhen the form is loaded? Like, (if field null, then update)?
 

Changing Existing VBA Code to an event procedure

Changing Existing VBA Code to an event procedure Icon
I have recently inherited a DB that I need to make some changes to. There is a button on an unbound form that when clicked, launches some VBA code below ( I have only included the code I amhaving trouble with and not the entire copy of code):
[CODE]

The text denoted in green I have added to add the CRD No. field to the table that is generated from this procedure - it is an unbound checkbox on the unbound form. However, I think I have missed something, because I get an error when I try to run the process.
 

2010 VBA "do while" code in a macro

2010 VBA "do while" code in a macro Icon
In Access 2010, want to run perform a "do while" loop in a macro. I understand VBA is the way to do this. So, I think I want to run a VBA script in a macro.

This Macro runs against a Form that has a SubFrom (MainForm named "Expense ID" & SubForm, "Expense"). Macro is initiated by pressing a button.

I would like help with some VBA code showing how to perform the following:

1. Evaluate a field ("Activity") in the first record of Subform ("Expense") against condition "Is not Null".

2. If condition is true, set value of another field ("Post") in the same SubForm record to "1".

3. Move to next record and repeat steps 1 & 2 until all Subform records are evaluated.

4. Return to macro that initiated the VBA script to perform the next action in the macro.