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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Unbound Fields to Tables 1

Status
Not open for further replies.

RealNewbie

Technical User
Jan 12, 2003
2
AU
Hi Peoples,

Can someone please help we figure out how to save from an unbound Field into a Table. So far I have gathered information from various Locations and Come up with a Module that looks like so.

Public Function Save() As Boolean
Dim rst As ADODB.Recordset

On Error GoTo HandleErrors

Set rst = New ADODB.Recordset
rst.Open

With rst
!Supervisor = Table1.Supervisor
!CSR = Table1.CSR
!Pin = Table1.Pin
!CustName = Table1.CustName
!CustPh = Table1.CustPhone
!BParty = Table1.BParty
!BCountry = Table1.BCountry
!BCarrier = Table1.BCarrier
!AParty = Table1.AccessNumber
!ACountry = Table1.ACountry
!TimeLogged = Table1.TimeLogged
!DateLogged = Table1.DateLogged
.Update
End With
Save = True

ExitHere:
If Not rst Is Nothing Then rst.Close
Set rst = Nothing
Exit Function

HandleErrors:
Save = False
Resume ExitHere
End Function

Now I'm trying to call it from a command button but seem to be running into troubles.

Thanks Heaps In Advance :)
 
Try this.

Public Function Save() As Boolean
On Error GoTo HandleErrors
Dim dbs As Database, rst As Recordset

Set dbs = CurrentDb 'Referance the current database
Set rst = dbs.OpenRecordset("YourTableName") ' referance the table

If Not rst.EOF Then rst.MoveFirst
With rst
.Edit ' Edit Current Record
!Supervisor = Table1.Supervisor
!CSR = Table1.CSR
!Pin = Table1.Pin
!CustName = Table1.CustName
!CustPh = Table1.CustPhone
!BParty = Table1.BParty
!BCountry = Table1.BCountry
!BCarrier = Table1.BCarrier
!AParty = Table1.AccessNumber
!ACountry = Table1.ACountry
!TimeLogged = Table1.TimeLogged
!DateLogged = Table1.DateLogged
.Update 'Save Current Record
.MoveNext 'Move to the Next Record
End With
rst.Close ' the refence table
Set dbs = Nothing ' close the referance database
Save = True

ExitHere:
Exit Function

HandleErrors:
Save = False
Resume ExitHere
End Function


If these records are added to a table with no recoreds change the .Edit to .AddNew


Hope this helps
Pierre
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top