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

Vb Data Import Export

P: 11
i m using access2003 database for my Project. now i have to import data from another access database with the same table name. can any one please tell me how to import data from another access file using codes.please its urgent
Mar 20 '07 #1
Share this Question
Share on Google+
4 Replies


Dököll
Expert 100+
P: 2,364
Use the Update command, I'd have to look, to make sure. Just make sure the table/tables columns you are updating to in one database are also available and in the same sequence in the other. Also, you may consider posting to the Access forum as well, I am not yet an amateur at this, fancy techniques may be found there :-)
Mar 21 '07 #2

vijaydiwakar
100+
P: 579
i m using access2003 database for my Project. now i have to import data from another access database with the same table name. can any one please tell me how to import data from another access file using codes.please its urgent
see there are two ways to do so
1. use import facility of Access itself
2. Make two connections one to retrive date and another to insert this data in other database

for that open one recordset create Qry according to ur actual database and insert using connection object
this is the tech. for actual code u've to try it
I'm able to give it 2 u but i think if u do it by urself then it'll uprise ur confidance
bbye 'n take care
Mar 21 '07 #3

P: 11
. i wrote some codes in dao. i created a function : AddTableField

i m writing it in module so that it can be access from anywhere in the program
this is the code

Sub AddTableField(ptdfTableDef As DAO.TableDef, pstrFieldName As String, pintDatatype As Integer, Optional pintSize As Integer, Optional pblnFixedLength As Boolean, Optional pblnAutoIncrement As Boolean, Optional pblnAllowZeroLength As Boolean, Optional pblnRequired As Boolean, Optional pstrValidationText As String, Optional pstrValidationRule As String, Optional pvarDefaultValue As Variant)
Dim fldX As DAO.Field
Dim intSize As Integer

Set fldX = ptdfTableDef.CreateField()

fldX.OrdinalPosition = ptdfTableDef.Fields.Count

fldX.Name = pstrFieldName
fldX.Type = pintDatatype

If Not IsMissing(pblnAllowZeroLength) Then
If pintDatatype = dbText And pintSize > 0 Then
fldX.Size = pintSize
Else
fldX.Size = GetFieldSize(pintDatatype)
End If
Else
fldX.Size = GetFieldSize(pintDatatype)
End If

If fldX.Type = dbLong Then
If pblnAutoIncrement = True Then
fldX.Attributes = fldX.Attributes Or dbAutoIncrField
End If
End If

If fldX.Type = dbText Or fldX.Type = dbMemo Then
fldX.AllowZeroLength = True
End If

If Not IsMissing(pblnRequired) Then
fldX.Required = pblnRequired
End If

If Not IsMissing(pstrValidationText) Then
fldX.ValidationText = pstrValidationText
End If

If Not IsMissing(pstrValidationRule) Then
fldX.ValidationRule = pstrValidationRule
End If

If Not IsMissing(pvarDefaultValue) Then
fldX.DefaultValue = pvarDefaultValue
End If

ptdfTableDef.Fields.Append fldX

End Sub
.

still i cannot get the transfer done
Mar 23 '07 #4

P: 11
. i wrote some codes in dao. i created a function : AddTableField

i m writing it in module so that it can be access from anywhere in the program
this is the code
Expand|Select|Wrap|Line Numbers
  1. .
  2. Sub AddTableField(ptdfTableDef As DAO.TableDef, pstrFieldName As String, pintDatatype As Integer, Optional pintSize As Integer, Optional pblnFixedLength As Boolean, Optional pblnAutoIncrement As Boolean, Optional pblnAllowZeroLength As Boolean, Optional pblnRequired As Boolean, Optional pstrValidationText As String, Optional pstrValidationRule As String, Optional pvarDefaultValue As Variant)
  3. Dim fldX As DAO.Field
  4. Dim intSize As Integer
  5.  
  6. Set fldX = ptdfTableDef.CreateField()
  7.  
  8. fldX.OrdinalPosition = ptdfTableDef.Fields.Count
  9.  
  10. fldX.Name = pstrFieldName
  11. fldX.Type = pintDatatype
  12.  
  13. If Not IsMissing(pblnAllowZeroLength) Then
  14. If pintDatatype = dbText And pintSize > 0 Then
  15. fldX.Size = pintSize
  16. Else
  17. fldX.Size = GetFieldSize(pintDatatype)
  18. End If
  19. Else
  20. fldX.Size = GetFieldSize(pintDatatype)
  21. End If
  22.  
  23. If fldX.Type = dbLong Then
  24. If pblnAutoIncrement = True Then
  25. fldX.Attributes = fldX.Attributes Or dbAutoIncrField
  26. End If
  27. End If
  28.  
  29. If fldX.Type = dbText Or fldX.Type = dbMemo Then
  30. fldX.AllowZeroLength = True
  31. End If
  32.  
  33. If Not IsMissing(pblnRequired) Then
  34. fldX.Required = pblnRequired
  35. End If
  36.  
  37. If Not IsMissing(pstrValidationText) Then
  38. fldX.ValidationText = pstrValidationText
  39. End If
  40.  
  41. If Not IsMissing(pstrValidationRule) Then
  42. fldX.ValidationRule = pstrValidationRule
  43. End If
  44.  
  45. If Not IsMissing(pvarDefaultValue) Then
  46. fldX.DefaultValue = pvarDefaultValue
  47. End If
  48.  
  49. ptdfTableDef.Fields.Append fldX
  50.  
  51. End Sub
  52.  
.

still i cannot get the transfer done
Mar 23 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.