How can I copy a value onto blank cells below

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to copy a value onto the null cells below it. This should happen until
a new value is met, then this new value should be copied down etc.
This should exclude null cells in the process.

eg

code customer name
123 GAP
GE
BT
345 TR
IBM

But I want it to show

123 GAP
123 GE
123 BT
345 TR
345 IBM
 
In a module you can create a function with a global variant
' ==== Module ==============
Option Compare Database

Global OldValue As Double
Function GetOldValue(NewValue As Variant)
If Not IsNull(NewValue) Then
OldValue = NewValue
End If
GetOldValue = OldValue
End Function
'========End Module ========

In the query call the function above to fill the blank with the old value


SELECT GetOldValue(
Code:
) AS NewCode, [customer name]
FROM TableName

==========
Note: I don't know the purpose of this query, but the resault might be
different every time, depend on the sort of the query.
I would recomand saving the value n the table, so the resault will be always
the same
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top