Help me with this basic macro.

A

A

Hello,
I have a "table" with two fields "Campo1" and "Campo2".

Campo1 Campo2
290231000005 AED
290231000004
290231000003
290231000002
290231000001
290231000007 AUD
290231000006
290231000011
290231000010
290231000009
290231000008


My goal is to modify the "table" (or create a new table) like this:

Campo1 Campo2
290231000005 AED
290231000004 AED
290231000003 AED
290231000002 AED
290231000001 AED
290231000007 AUD
290231000006 AUD
290231000011 AUD
290231000010 AUD
290231000009 AUD
290231000008 AUD

Basically I have to check "Campo2" and copy the text when there's a
"blank" entry...
If you can help me with a simple code I'd be able to understand how to
check tables, field and do cycles between them and write my own code.

Thank you.

Ale.
 
B

banem2

Hello,
I have a "table" with two fields "Campo1" and "Campo2".

Campo1                              Campo2
290231000005            AED
290231000004
290231000003
290231000002
290231000001
290231000007            AUD
290231000006
290231000011
290231000010
290231000009
290231000008

My goal is to modify the "table" (or create a new table) like this:

Campo1                               Campo2
290231000005            AED
290231000004            AED
290231000003            AED
290231000002            AED
290231000001            AED
290231000007            AUD
290231000006            AUD
290231000011            AUD
290231000010            AUD
290231000009            AUD
290231000008            AUD

Basically I have to check "Campo2" and copy the text when there's a
"blank" entry...
If you can help me with a simple code I'd be able to understand how to
check tables, field and do cycles between them and write my own code.

Thank you.

Ale.

Hi,

You will need to use VBA code. Assuming the order of the records is as
provided, this code might help (air-code, untested, no error-
handling):

Dim rst As Recordset
Dim strCampo As String
Set rst = CurrentDb.OpenRecordset("table")

With rst
Do Until .EOF
If Len(!Campo2) > 0 Then
strCampo = !Campo2
ElseIf Len(strCampo) > 0 Then
.Edit
!Campo2 = strCampo
.Update
End If
.MoveNext
Loop
End With

Regards,
Branislav Mihaljev
Microsoft Access MVP
 
Top