13. september 2005 - 11:56Der er
63 kommentarer og 1 løsning
Splitfunktion i notatfelt
Jeg har i spørgsmål www.eksperten.dk/spm/635904 fået fint svar på hvordan jeg finder et Journalnr xxxxx i et notatfelt. Men nu har jeg brug for at kunne finde flere af disse Journalnr xxxxx i samme notatfelt. Disse Journalnr xxxxx kan være forskellige og logger i det samme notatfelt. Hvordan får jeg læst disse Jornalnr xxxxxx, Journalnr yyyyy over i en tabel eller over i en fil ?
Public Function Journal(felt1) Dim VARa As String Dim O As Variant Dim i As Integer
If Len(felt1) > 0 Then O = Split(felt1, "journalnr") If UBound(O) > 0 Then DoCmd.SetWarnings False For i = 1 To UBound(O) VARa = Left(O(i), 7) Journal = Right(VARa, 6)
Jeg prøver at kalde funktionen fra en forespørgsel. Udtryk1: Journal([notatfeltet]) men den dør på kørsel af sql. I forespørgslen har jeg også andre call's
Funktionen fangede godt nok det sidste Journalnr og lagde det i forespørgslen. Men meningen var jo også at det skulle lægges i en særlig tabel med hver sin række.
Hej Terry. Måske har du tid. Jeg har problemer med at få sql til at køre fra funktionen. Kan jeg mangle en reference eller andet. Jeg har prøvet at lave en tilføjelsesforespørgsel og lagt den ind i funktionen. Den vil heller ikke afvikle docmd.runsql
no message. jeg har også prøvet at slå warnings fra. Der kommer ingen fejltekst. Proceduren blir ikke kaldt på den rigtige måde. Jeg anvender en knap: Call Journal(notatfeltet) og koden i proceduren:
Public Function Journal(notatfeltet) Dim VARa As String Dim O As Variant Dim i As Integer If Len(notatfeltet) > 0 Then O = Split(notatfeltet, "Journalnr") If UBound(O) > 0 Then
'DoCmd.SetWarnings False
For i = 1 To UBound(O) VARa = Left(O(i), 7) Journal = Right(VARa, 6)
Next i Else Journal = "Journalnr findes ikke" End If
'DoCmd.SetWarnings True End If End Function ,,,,,,,,,,, jeg har en tabel: tbloplysninger med et felt "notatfeltet". Og jeg har en tabel Data_udtræk med et felt "Data" som også har notatformat ,,,,,,,,,,, Journalnr skal udtrækkes fra "notatfeltet"(kun en række) og insertes i "Data" hvor der gerne skulle optræde flere rækker med de fundne Journalnr. Går til frokost nu.
I can set a toggle breakpoint. Er det OK. Og hvilken button do I press. I have made a macro med the sql, and can execute outside the procedure. I tried put the macro insode the procedure, but it did not execute
The reason why I place NOSPAM in my email address when making it public is to limit the SPAM I receive!!!! So NOSPAM must be removed from the email address.
Do you have an email address I can send a mail to?
Yes I have: susannehougaard@mail.dk But now i mdb works. I did not have my tbl in the form. I just had a button without no data in the form. Is it possible to get the funktion to execute without the data. Can I write to the button in code that it has to tke the data from the tbl field.
I do understand danish (almost 100%) so you do not need to answer in English.
The function will work as long as you give it some data! But as I dont know exactly how you want to use it then its hard to give an example.
Something else you should concider:
You should maybe have another table where you write your information on each Journal. Having to find the information in one memo field isnt the best method.
Ja vi er der faktisk og det virker. Kan du ændre koden så den samtidig finder opretteren. F eks "xxx xxcdd tekst "Journalnr 345666" cxcmdk tekst dllf "Oprettet af Peter Nielsen" sdllæssææ tekst dææføøøas teskstjkll "Journalnr 888889" llæas dlls "Oprettet af Niels Nielsen"
when searching for Journalnr then we know that the number is six charactres. The problem in search for "Opretteren" is we dont know how long the name is, or do we?
I suggest that you consider normalizing your database, this will make things MUCH easier.
Ja, Ja Terry. Men det skulle jo bygges sammen med det der Journalnr. Koden skal gennemløbe notatfeltet og finde både Journalnr og Opretter i samme gennemløb. Kan man det ? og hvordan ser den sammebyggede kode ud ? Journalnr skulle lægges i den ny tabel i felt1 og Opretteren i samme tabel men bare i felt2.
Public Function Journal2(notatfelt) Dim VARa As String Dim VARb As String Dim O As Variant Dim p As Variant Dim i As Integer Dim opretteren As String Dim Journal As String
If Len(notatfelt) > 0 Then O = Split(notatfelt, "Journalnr") p = Split(notatfelt, "Oprettet af")
msgbox Ubound(O) & " - " UBound(P) If UBound(O) > 0 Then
'DoCmd.SetWarnings False
For i = 1 To UBound(O) VARa = left(O(i), 7) Journal = Right(VARa, 6) opretteren = Mid(p(i), 2, 30)
I think the original question is answered now, but I can take a look at this if you can send me your database. If I cant see the data and the code then its very hard to find out what is wrong.
You have my email. If your mails do notget through then I suspect that your mail server is stopping it.
Hi Susanne Do you think we could close this question now? The original question has been answered. If you need further help when you have more time then you can just place a comment here.
thanks There is a problem when trying to give points, it is necessary to choose the name in the laist and then accept.
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.