By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,107 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,107 IT Pros & Developers. It's quick & easy.

Fill blank field with data

P: n/a
I have a database with fields "ID" and "DocName" that is sorted by ID.
A sample of the record data is:
1, OneDoc
2, null
3, null
4, null
5, AnotherDoc
6, null
7, null
8, null
9, YetAnotherDoc
10, null.

I would like to autofill the records with the following results:

1, OneDoc
2, OneDoc
3, OneDoc
4, OneDoc
5, AnotherDoc
6, AnotherDoc
7, AnotherDoc
8, AnotherDoc
9, YetAnotherDoc
10, YetAnotherDoc.

I can copy and paste, and do an update query, but hope to find a
procedure that will be faster.

Thanks for the help!
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
AFAIK, an update query will be the fastest to execute.

Otherwise, you could write DAO code in VBA to read the table (use a Query
that sorts on ID, just to make sure), and save the DocName if it isn't
empty/null, set it from the saved value if it is empty/null.

Dim db as Database
Dim rs as Recordset
Dim strSQL as String

Set db = CurrentDB()
strSQL = "SELECT ID,DocName FROM yourtable ORDER BY ID"
Set rs = db.OpenRecordset (strSQL)
rs.MoveFirst
Do Until rs.EOF
If Len(rs.DocName)<>0 Then
strDocName = rs.DocName
Else
rs.Edit
rs.DocName = strDocName
rs.Update
End If
rs.MoveNext
Loop
rs.Close

Substitute your table's name for "yourtablename" in the statement setting
strSQL.
"Jake Brooks" <ja**@digidatacorp.com> wrote in message
news:85**************************@posting.google.c om...
I have a database with fields "ID" and "DocName" that is sorted by ID.
A sample of the record data is:
1, OneDoc
2, null
3, null
4, null
5, AnotherDoc
6, null
7, null
8, null
9, YetAnotherDoc
10, null.

I would like to autofill the records with the following results:

1, OneDoc
2, OneDoc
3, OneDoc
4, OneDoc
5, AnotherDoc
6, AnotherDoc
7, AnotherDoc
8, AnotherDoc
9, YetAnotherDoc
10, YetAnotherDoc.

I can copy and paste, and do an update query, but hope to find a
procedure that will be faster.

Thanks for the help!

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.