02. marts 2005 - 15:59Der er
12 kommentarer og 1 løsning
VB script, INSERT INTO
Hej folkens.
Jeg har en db med 3 tabeller.
sælger, kunde og sælger-kunde-relation
Jeg skal primært arbejde på relationstabellen. VB-scriptet kender sælgeren og kunden... det skal bare indsætte en ny række i tabellen sælger-kunde-relation med disse data.
Ikke helt det svar jeg ønskede. SQL-delen er ikke den ukendte for mig, hvorimod det at forbinde og foretage kald til databasen via VB står mig meget, meget fjernt.
If you make your tables first and the relationships are in place, then you should be able to make a form using the form wizard. This should make a form containing a subform.
In the sælger-kunde-relation table when you are in design view choose the Lookup as the data type. This will start a wizard which will help you make the relationship to the related tables. When you are finished you should end up with two combo boxes where you can choose sælger and kunde.
Now make a query where you have the sælger-kunde-relation table and the kunde table. Choose ALL fields from both both tables.
Now make a form using the form wizard. Choose the sælger table AND the query you just made for the data you want to use on the form. Now hopefully you should end up with a form containing sælge and a sub form containig the sælger-kunde-relation and kunde data (from the query).
You may need to alter the field type FROM text to combo
The main form should contain "sælger" and the sub form information from the other two tables (query). Some of the fields are in fact NOT needed, they get automatically filled out when you choose a Kunde.
I have this: --------------------------- kunde_sælger_relation (table) --------------------------- kundenr : Text Sælger : Number startdato : Date/Time slutdato : Date/Time
---------------------------------- Form with two text boxes ---------------------------------- txt_kunde_dummy (Kunder.Kundenr) txt_salger_dummy (Sælgere.ID)
---------------------------------- These relations ---------------------------------- kunde_sælger_relation.kundenr --> Kunder.Kundenr kunde_sælger_relation.Sælger --> Sælgere.ID --- And i would like to execute these two queries: ---------------------------------------------------------- 1. UPDATE kunde_sælger_relation SET slutdato = NOW() WHERE kunde_sælger_relation.kundenr = txt_kunde_dummy AND kunde_sælger_relation.slutdato = ""
2. INSERT INTO kunde_sælger_relation VALUES (txt_kunde_dummy, txt_salger_dummy, NOW()+1, NULL) ----------------------------------------------------------
Is it possible to do this by making the two queries in design-mode and then running them from a VB script?
sSQL = "UPDATE kunde_sælger_relation SET kunde_sælger_relation.slutdato = Now() WHERE (((kunde_sælger_relation.slutdato) = NULL) AND ((kunde_sælger_relation.kundenr)= """ & [Forms]![frm_Admin].[txt_kunde_dummy].[Value] & """));"
it is the part where i want to pick only those posts with slutdato = NULL but NONE of the fields equals NULL... - the question is, I guess: Wvat is the NULL-value of a date/time field? ... aparently not NULL
the best way to get your SQL working is use the query builder. TYhen when its working there you can copy it to your code.
Try Is Null
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.