Avatar billede rickie Juniormester
18. oktober 2006 - 13:24 Der er 10 kommentarer og
1 løsning

Select og så MsgBox inden Insert

Hej,

Har fölgende:
Private Sub btnSelective_Click()
DoCmd.SetWarnings False
Dim sSQL As String

    If IsNull(txtBeloppFrån) Then
        MsgBox "Du måste ange belopp!", vbCritical, "kundtyp!"
        Me.txtBeloppFrån.BackColor = vbRed
        Me.txtBeloppFrån.SetFocus
    ElseIf IsNull(txtBeloppTill) Then
        MsgBox "Du måste ange belopp!", vbCritical, "kundtyp!"
        Me.txtBeloppTill.BackColor = vbRed
        Me.txtBeloppTill.SetFocus
    ElseIf IsNull(txtSekvens) Then
        MsgBox "Du måste ange sekvens!", vbCritical, "kundtyp!"
        Me.txtSekvens.BackColor = vbRed
        Me.txtSekvens.SetFocus
    Else

sSQL = "INSERT INTO tblBook ([brvCustomerNo], [brvSequence], [brvAmount])" & vbCrLf & _
"SELECT (CUS.[No_]), (RBC.[Rent Sequence]), SUM(CLE.[Remaining Amount])" & vbCrLf & _
"FROM [dbo_vw_Thorn_Svenska_AB$Customer] AS CUS, [dbo_vw_Thorn_Svenska_AB$Cust__Ledger_Entry] AS CLE, [dbo_vw_Thorn_Svenska_AB$Rent_Billing_Customer] AS RBC" & vbCrLf & _
"WHERE CLE.[Customer No_] = RBC.[Customer No_] AND CUS.[No_] = RBC.[Customer No_] AND CLE.[Open] = 1 AND CLE.[Ledger Type] = 2 AND RBC.[Customer Status Rent] = 0 AND CUS.[No_] BETWEEN '" & txtKundnummerFrån.Value & "' AND '" & txtKundnummerTill.Value & "'  AND RBC.[Rent Sequence] = " & txtSekvens.Value & " AND CLE.[Remaining Amount] BETWEEN '" & txtBeloppFrån.Value & "' AND '" & txtBeloppTill.Value & "' " & vbCrLf & _
"GROUP BY (CUS.[No_]), (RBC.[Rent Sequence]) "
DoCmd.RunSQL sSQL
 
MsgBox "Så här många kunder blev selekterade. Önskar du att boka breven?"
 
End If
End Sub

Linjen med MsgBox vil jeg gerne vise hvor mange kunder som blev udvalgt. Hvis svar JA så gemmes de i tabellen og hvis nej så droppes de.
Avatar billede terry Ekspert
18. oktober 2006 - 18:49 #1
"....vil jeg gerne vise hvor mange kunder som blev udvalgt".
Where does that information come from, txtKundnummerFrån to txtKundnummerTill?

THat would only give you an interval which may NOT be the actual number of "kunde".

You could alter your msgbox text to show the interval

If msgbox("You have chosen from customer .....", vbYesNo ) = vbYes Then

'Do your insert

End if
Avatar billede terry Ekspert
18. oktober 2006 - 18:49 #2
rickie are youhaving problems sending me your dB?
Avatar billede rickie Juniormester
18. oktober 2006 - 23:47 #3
Hey Terry,

I look into it tomorrow. Yes it seems like there are problems with sending you my DB. I´ve sent it several times - from home and work and the last time even with a reciept. I don´t get any errors or Adnin mail that tells me that an error has acoured. Strange!Do you have en FTP or something?
Avatar billede terry Ekspert
19. oktober 2006 - 12:39 #4
Yes I have an FTP but it snot open for uploading. If you look at my profile you will find a link to my homepage and here you can choose email from the menu. Try using that address
Avatar billede rickie Juniormester
21. oktober 2006 - 08:55 #5
Hey Terry! I still can´t send the DB to you. Seems like my mailserver from work and home wont accept it - weird because i can send it between my own mail and to others but not to you. I will look into if i can set up an FTP so you can get it from that :-)

About the Msgbox: Can you type the exact code because i dont know which command that actualy will show the "count kunde" in the MsgBox :-)
Avatar billede terry Ekspert
21. oktober 2006 - 13:20 #6
you can also try sending it to
sandyATstofanet.dk

replace AT with @

it isnt possible to give a count. You would first need to use som eother code to find out how many are in the inteval. That is why I suggested showing the interval in the msgbox
Avatar billede rickie Juniormester
24. oktober 2006 - 11:00 #7
Hej Terry,

Nu er den sendt till sandyATstofanet.dk
Avatar billede terry Ekspert
24. oktober 2006 - 11:54 #8
I have received it now, will take a look as soon as possible
Avatar billede terry Ekspert
25. oktober 2006 - 17:53 #9
I have sent you a mail which I need an answer on
Avatar billede rickie Juniormester
30. oktober 2006 - 13:18 #10
Hey Terry,

I havent recieved it! It´s odd that there are problems with my mail! Send it again please :-) rickie.grayholm[at]telia.com or rickie.grayholm[at]thorn.no
Avatar billede terry Ekspert
30. oktober 2006 - 13:51 #11
Yes it look sa sthough you have problems with your emails.

Anywaym what I want to know is hwich question(s) are still actual? You have accepted some and placed new, so i'm a bit los as to which ones you need help on.
Avatar billede Ny bruger Nybegynder

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.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester