Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Table Query Question

Status
Not open for further replies.

Legacy123

IS-IT--Management
Oct 16, 2006
3
US
This is giving me a pain.
I have a source table with a text field that some values are empty. In my create table query, I want to populate the empty fields with "Shell" when ran.
I am playing with this design view criteria
IIf([Merged_Pricelist_with_Inventory]![Product]=Null,[Merged_Pricelist_with_Inventory]![Product]="Shell",[Merged_Pricelist_with_Inventory]![Product])
This only show records that had a value for product.

Thanks for any help
 
Code:
IIf([Merged_Pricelist_with_Inventory]![Product]=Null,"Shell",[Merged_Pricelist_with_Inventory]![Product])
 
The result is the same. It takes out the rows that had an empty "Product" field. I tried "" also, as in IIf([Merged_Pricelist_with_Inventory]![Product]="","Shell",[Merged_Pricelist_with_Inventory]![Product]) , that does the same thing. Am I better of using ADO and SQL Update statments in VBA?

Thanks
 
This worked for me>
Sub Populate_Product()

Dim conn As ADODB.Connection
On Error GoTo ErrorHandler
Set conn = CurrentProject.Connection

conn.Execute "UPDATE Final_Table SET Product = 'Shell' WHERE Product Is Null;"
Application.RefreshDatabaseWindow

ExitHere:
conn.Close
Set conn = Nothing
Exit Sub
ErrorHandler:
MsgBox Err.Number & ": " & Err.Description, _
vbCritical, "Alter Merged Pricelist"
Resume ExitHere
End Sub

Thanks Anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top