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

Make table from code?

P: n/a
Hi!
A form load with the following code (3 listboxes):

With Me!lstOnr
.RowSource = ""
.ColumnCount = 6
.ColumnHeads = True
.ColumnWidths = "0cm;1,501cm;1,752cm;0cm;0cm;1,501cm"
.BoundColumn = 1
.RowSource = "SELECT tblOrdrer.OrdreID, tblOrdrer.Ordrenr,
tblOrdrer.Dato, tblOrdrer.KundeID, tblOrdrer.AnsattID,
tblAnsatte. Initialer, tblOrdrer.Returnr " _
& "FROM tblAnsatte
INNER JOIN tblOrdrer ON tblAnsatte.AnsattID = tblOrdrer.AnsattID " _
& "WHERE (((tblOrdrer.OrdreNr) = Forms!frmOrdrer!OrdreNr));"
End With

With Me!lstPersOppl
.RowSource = ""
.ColumnCount = 7
.ColumnHeads = True
.ColumnWidths = "0cm;1,251cm;4cm;4cm;0cm;1,255cm;4cm"
.BoundColumn = 1
.RowSource = "SELECT tblKunder.KundeID, tblKunder.Kundenr, tblKunder.Navn,
tblKunder.Adresse, tblKunder.PostnrID, tblPostnr.Postnr, tblPostnr.Sted " _
& "FROM tblPostnr
INNER JOIN tblKunder ON tblPostnr.PostnrID = tblKunder.PostnrID " _
& "WHERE (((KundeID) = Forms!frmOrdrer!KundeID));"
End With

With Me!lstVareInfo
.RowSource = ""
.ColumnCount = 9
.ColumnHeads = True
.ColumnWidths = "0cm;2cm;0cm;4cm;4cm;1,251cm;1,251cm;1,251cm;1,251 cm"
.BoundColumn = 1
.RowSource = "SELECT tblDelordrer.OrdreID, tblDelordrer.DelordreID,
tblDelordrer.VareID, tblVarer.Varenavn, tblVarer.VareDimensjon,
tblDelordrer.Pris, tblDelordrer.Mengde, tblDelordrer.Rabatt,
tblDelordrer.Miljoavg " _
& "FROM tblVarer
INNER JOIN tblDelordrer ON tblVarer.VareID = tblDelordrer.VareID " _
& "WHERE (((tblDelordrer.OrdreID) = Forms!frmOrdrer!OrdreID));"
End With

Now...

Can I make a table, say tblMyTemp, filled with these data in code?

The purpose is to fill a table with data that I want to send to a report.

Any suggestions?

Me.Name
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Geir Baardsen wrote:
Hi!
A form load with the following code (3 listboxes):

With Me!lstOnr
.RowSource = ""
.ColumnCount = 6
.ColumnHeads = True
.ColumnWidths = "0cm;1,501cm;1,752cm;0cm;0cm;1,501cm"
.BoundColumn = 1
.RowSource = "SELECT tblOrdrer.OrdreID, tblOrdrer.Ordrenr,
tblOrdrer.Dato, tblOrdrer.KundeID, tblOrdrer.AnsattID,
tblAnsatte. Initialer, tblOrdrer.Returnr " _
& "FROM tblAnsatte
INNER JOIN tblOrdrer ON tblAnsatte.AnsattID = tblOrdrer.AnsattID " _ & "WHERE (((tblOrdrer.OrdreNr) = Forms!frmOrdrer!OrdreNr));"
End With

With Me!lstPersOppl
.RowSource = ""
.ColumnCount = 7
.ColumnHeads = True
.ColumnWidths = "0cm;1,251cm;4cm;4cm;0cm;1,255cm;4cm"
.BoundColumn = 1
.RowSource = "SELECT tblKunder.KundeID, tblKunder.Kundenr, tblKunder.Navn, tblKunder.Adresse, tblKunder.PostnrID, tblPostnr.Postnr, tblPostnr.Sted " _ & "FROM tblPostnr
INNER JOIN tblKunder ON tblPostnr.PostnrID = tblKunder.PostnrID " _ & "WHERE (((KundeID) = Forms!frmOrdrer!KundeID));"
End With

With Me!lstVareInfo
.RowSource = ""
.ColumnCount = 9
.ColumnHeads = True
.ColumnWidths = "0cm;2cm;0cm;4cm;4cm;1,251cm;1,251cm;1,251cm;1,251 cm" .BoundColumn = 1
.RowSource = "SELECT tblDelordrer.OrdreID, tblDelordrer.DelordreID, tblDelordrer.VareID, tblVarer.Varenavn, tblVarer.VareDimensjon,
tblDelordrer.Pris, tblDelordrer.Mengde, tblDelordrer.Rabatt,
tblDelordrer.Miljoavg " _
& "FROM tblVarer
INNER JOIN tblDelordrer ON tblVarer.VareID = tblDelordrer.VareID " _ & "WHERE (((tblDelordrer.OrdreID) = Forms!frmOrdrer!OrdreID));"
End With

Now...

Can I make a table, say tblMyTemp, filled with these data in code?

The purpose is to fill a table with data that I want to send to a report.
Any suggestions?

Me.Name


Am I missing something here? Why not use a query to gather the data
required, then use the query as the Record Source of the Report?

Nov 13 '05 #2

P: n/a
"Geir Baardsen" <ge***********@hotmail.com> wrote
A form load with the following code (3 listboxes):

With Me!lstOnr
.RowSource = ""
.ColumnCount = 6
.ColumnHeads = True
.ColumnWidths = "0cm;1,501cm;1,752cm;0cm;0cm;1,501cm"
.BoundColumn = 1
.RowSource = "SELECT tblOrdrer.OrdreID, tblOrdrer.Ordrenr,
tblOrdrer.Dato, tblOrdrer.KundeID, tblOrdrer.AnsattID,
tblAnsatte. Initialer, tblOrdrer.Returnr " _
& "FROM tblAnsatte
INNER JOIN tblOrdrer ON tblAnsatte.AnsattID = tblOrdrer.AnsattID " _
& "WHERE (((tblOrdrer.OrdreNr) = Forms!frmOrdrer!OrdreNr));"
End With

With Me!lstPersOppl
.RowSource = ""
.ColumnCount = 7
.ColumnHeads = True
.ColumnWidths = "0cm;1,251cm;4cm;4cm;0cm;1,255cm;4cm"
.BoundColumn = 1
.RowSource = "SELECT tblKunder.KundeID, tblKunder.Kundenr, tblKunder.Navn, tblKunder.Adresse, tblKunder.PostnrID, tblPostnr.Postnr, tblPostnr.Sted " _ & "FROM tblPostnr
INNER JOIN tblKunder ON tblPostnr.PostnrID = tblKunder.PostnrID " _
& "WHERE (((KundeID) = Forms!frmOrdrer!KundeID));"
End With

With Me!lstVareInfo
.RowSource = ""
.RowSource = "SELECT tblDelordrer.OrdreID, tblDelordrer.DelordreID,
tblDelordrer.VareID, tblVarer.Varenavn, tblVarer.VareDimensjon,
tblDelordrer.Pris, tblDelordrer.Mengde, tblDelordrer.Rabatt,
tblDelordrer.Miljoavg " _
& "FROM tblVarer
INNER JOIN tblDelordrer ON tblVarer.VareID = tblDelordrer.VareID " _
& "WHERE (((tblDelordrer.OrdreID) = Forms!frmOrdrer!OrdreID));"
End With
I will reply to the code-table-query issue in another email. But what
needs to be pointed out here is that you are needlessly setting all these
properties in the onOpen event. Set the properties of the listboxes at
design time, in design view.

Certainly these:
.ColumnCount = 9
.ColumnHeads = True
.ColumnWidths = "0cm;2cm;0cm;4cm;4cm;1,251cm;1,251cm;1,251cm;1,251 cm"
.BoundColumn = 1


Should rarely be set in code, unless you are for some reason using the same
listbox for multiple queries of very different type.

Setting the RowSource to a blank string is useless if you turn around and
set it to a SQL query just a few lines later.

Why not just have the rowsource already part of the listbox? Why do this on
open at all??
Darryl Kerkeslager
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.