I am a beginner and attempting to "retrofit" an old .mdb (which is essentially a flat file) and move the old "cleaned up" data into my new normalized database. To do this, I am creating several procedures in a module and running from the Immediate Window. (And for other data updates/moves am using Update queries).
The current procedure I'm working with creates 2 RSs (Old [the source] and New [the target]), loops through the old, stuffs variables, then transfers the contents of the variables into the new RS record by record. To prevent
VB complaints, I used the NZ function against the field before stuffing into the variable. The procedure "steps through" until it gets to updating the new table. Then it errors with "field name cannot be a 0 length string". The new table appears to accept the data (a 0 length string where the original text field was empty) when I change the property "allow 0 length strings" = true..... but before I procede, could I get some advise from experienced heads, please??
If I allow fields to contain 0 length strings in the new table, are there other code strategy changes I'll need to make? (I imagine "IsNull" will no longer work)....
As the tables are populated with more data, will they take up more space if empty text and memo fields contain a 0 length string as opposed to a null?
Can I change a 0 length string back to a null? (I could not find a function to do that when I looked).
Thanks,
Loralee
Sub PopulateCTUProviders()
' use to populate tblCTUPVendor from the old CTU database data
Dim lngContactID As Long
Dim strBusAddress As String
Dim strBusCity As String
Dim strPhone As String
Dim strFax As String
Dim strCategory As String
Dim blnActive As Boolean
Dim strComments As String
Dim strPrint As String
Dim db As DAO.Database
Dim rsOLD As DAO.Recordset
Dim rsNew As DAO.Recordset
Set db = CurrentDb
Set rsOLD = db.OpenRecordset("ctuproviders", dbOpenDynaset)
Set rsNew = db.OpenRecordset("tblCTUVendor", dbOpenDynaset)
rsOLD.MoveFirst
Do While Not rsOLD.EOF
lngContactID = Nz(rsOLD!contactid)
strBusAddress = Nz(rsOLD!busaddress)
strBusCity = Nz(rsOLD!buscity)
strPhone = Nz(rsOLD!phone)
strFax = Nz(rsOLD!fax)
strCategory = Nz(rsOLD!Category)
blnActive = Nz(rsOLD!active)
strComments = Nz(rsOLD!comments)
strPrint = Nz(rsOLD!Print)
With rsNew
.MoveFirst
.FindFirst "[contactidtemp] = " & lngContactID
If rsNew.NoMatch Then
MsgBox "There is no match for provider"
Exit Sub
Else
.Edit
!busaddress = strBusAddress
!BusCityTemp = strBusCity
!busphone = strPhone
!busfax = strFax
!Categorytemp = strCategory
!active = blnActive
!comments = strComments
!Print = strPrint
.Update
End If
End With
rsOLD.MoveNext
Loop
rsNew.Close
rsOLD.Close
Set rsOLD = Nothing
Set rsNew = Nothing
End Sub