Jump to content
smengayau

Dari Access Ke Excel

Recommended Posts

assalam,mualaikum...

leh tolong tak..... saya baru belajar nak buat database..

mcm mana kita nak link kan data kita dari ms access ke ms excel?
contohnya...
saya ada data dalam ms access dan saya ada buat tamplet kat ms excel.
mcm mana saya nak masukkan data yang telah siap dalam ms access tu nak di link ke tamplet di ms excel?? maksud saya... apa arahan dalam form tu yang ke di ubah atau perlukan satu form khas untuk link kan ke 2-2 ms tu???

Share this post


Link to post
Share on other sites
yeaa .. saye cube bantu .. sebelom tu saye nak tanye awak .. data yang masuk tu data yang gunakan SQL yang sama atau berlainan ... i mean template yang kamu gunakan susun data sama macam database tak ..?

Share this post


Link to post
Share on other sites
Bro U try That ... i'll build for U ...



Dim sqlstr As String
sqlstr = "CREATE TABLE tlkp_ContactType " & _
"(ContactType text, Description text)"
DoCmd.RunSQL sqlstr

' Now add the unique data from the imported contacts table
' This is the SQL equivalent of an Append action query

sqlstr = "INSERT INTO tlkp_ContactType " & _
"( ContactType, Description ) " & _
"SELECT ContactType, ContactType AS Description " & _
"FROM Contacts " & _
"GROUP BY ContactType, ContactType;"

Call ChangeTitle_FX("Appending To tlkp_ContactType")
DoCmd.RunSQL sqlstr

Another of these SQL commands creates a primary index on the Lookup table.

sqlstr = "CREATE UNIQUE INDEX " & _
" MyIndex ON tlkp_ContactType (ContactType) With Primary"
DoCmd.RunSQL sqlstr

Now I use a DAO library method to build a one to many cascading relationship between the tables. This has no equivalent command in SQL or in ADO. To find help on this topic, use Access 97 if you can because the DAO help in Access 2000 is very elusive. A good practice illustrated here is to add the "DAO." definition to all DAO objects. When I was developing this routine, I spent a long time debugging this code in Access 2000 because ADO took precedence and the errors that were returned on the append method lead me on a wild goose chase.

Dim dbsBuild As DAO.DATABASE
Dim relatNew As DAO.Relation
Set dbsBuild = CurrentDb
Set relatNew = dbsBuild.CreateRelation("MyRelationship", _
"tlkp_ContactType", "contacts", _
dbRelationUpdateCascade)

With relatNew

' Need to create a field in relation object prior to
' defining the name of the external field.

.Fields.Append .CreateField("ContactType")
.Fields!ContactType.ForeignName = "ContactType"
dbsBuild.Relations.Append relatNew

End With

And to complete the process, the building routine initially has to delete the relationship and the the lookup table in case either of them exist in the database. This deletion of relationships using code is important as the SQL drop table command will not work whilst a relationship is in place. Note that I turn off the error tracking for this section of the code so that the software will just continue on if the tables and relationships do not exist.

On Error Resume Next

' Delete the relationship if it exists

Set dbsBuild = CurrentDb
With dbsBuild
.Relations.Delete "MyRelationship"
.Close
End With

' Delete the table in case it exists.

DoCmd.RunSQL "Drop table tlkp_ContactType"
On Error GoTo 0

Share this post


Link to post
Share on other sites
saya guna visual basic... ekekeke.... saya baru nak belajar ba ni... saya ada 1 software database orang punya... saya teringin sangat nak buat... yang saya tengok tu.. dalam cd tu just ada mc access dan ms excel yang mana templetnya ada pada ms excel dan datanya ada pada ms access. ekeke... tolong terangkan pada saya napa mcm tu.... saya tak faham.. maklumlah tak ada sekolah tinggi ni... bye.. Edited by smengayau

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...