Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Forum översikt / inlägg

Posta nytt inlägg


"Rapport programmering"???

Postades av 2004-06-30 02:26:48 - Jakob Hägg, i forum access, Tråden har 7 Kommentarer och lästs av 1491 personer

Hej!

Jag har en fet databas i access som jag vill göra så att man kan visa med en rapport i access. Men det är två saker jag inte får till:

1. Jag vill kunna ta fram bara några poster. Alltså få rapporten att fatta en WHERE namn<>''.
2. Jag vill göra om ett tal t.ex. 210 till hela timmar och minuter. Så att 210 blir 03:30.

Någon som kan hjälpa mig?

mvh Jakob Hägg


Svara

Sv: "Rapport programmering"???

Postades av 2004-06-30 08:11:20 - Andreas Hillqvist

<b>1. Jag vill kunna ta fram bara några poster. Alltså få rapporten att fatta en WHERE namn<>''.</b>

WHERE namn Is Not Null

<b>2. Jag vill göra om ett tal t.ex. 210 till hela timmar och minuter. Så att 210 blir 03:30.</b>

=DateAdd("n",[FältMedMinuter],0)


Svara

Sv: "Rapport programmering"???

Postades av 2004-06-30 10:33:37 - Jakob Hägg

<b>WHERE namn Is Not Null</b>

Vart skriver man in det? Jag har letat som en galning efter sql frågan.

<b>=DateAdd("n",[FältMedMinuter],0)</b>

"Uttryckets syntax är ogiltlig" fick jag på den?


Svara

Sv: "Rapport programmering"???

Postades av 2004-06-30 10:49:05 - Andreas Hillqvist

<b>Vart skriver man in det? Jag har letat som en galning efter sql frågan.</b>

Egenskapen datakälla på formuläret.

<b>"Uttryckets syntax är ogiltlig" fick jag på den?</b>

Testa med:
=DateAdd("n";[FältMedMinuter];0)

Tänk på att kontrolen INTE får heta samma som fältet!


Svara

Sv: "Rapport programmering"???

Postades av 2004-06-30 10:57:28 - Jakob Hägg

<b>Testa med:
=DateAdd("n";[FältMedMinuter];0)

Tänk på att kontrolen INTE får heta samma som fältet!
</b>

Så i mitt fall skriver jag =DatumLäggTill("n";[borjar];0)???
När jag skriver det så skriver han bara ut #Namn?


Svara

Sv: "Rapport programmering"???

Postades av 2004-06-30 12:04:15 - Andreas Hillqvist

Finns [borjar] med i din SQL fråga? Finns det någon kontroll med namnet borjar?


Svara

Sv: "Rapport programmering"???

Postades av 2004-07-01 18:06:32 - Jakob Hägg

Alltså jag har inget formulär så jag har inte fått fram själva sql frågan... Men det fungerar att bara skriva ut borjar...


Svara

Sv: "Rapport programmering"???

Postades av 2004-07-04 00:07:17 - paul horsley

Hi,
your secound question

how to get 210 MINUTES presented as hrs + minutes, not so simple, first it can't be done with out you writing a user defeined function. As it is only presentation your after I guess you could use something like..

SELECT System.Element, [Data]/60 AS Hrs
FROM System
WHERE (((System.Element)="TM"));

so your 210 ( str or numeric value divied by 60 = 3.5

Would this be good enough?

If not you'll have to make a quick UDF and use it in your sql command.

As to your question number one....
If using acc 200 you can have this code snippet, it should guide you how to use a function to open a report invisible and set the runtime sql ( where clause will be decided at runtime right?)
and then save and close the report and then open it in acviewnormal or acviewpreview.

Read the code first then ask me questions, if you have any...
It has a lot more than you need but you should be able to cut n paste your way to a working sub
'******************************************start
Public Function PrintReport(ByVal Prefix As String, ByVal TheReportNameToPrint As String, LstClients As ListBox, frm As Form, ByVal AllowPrint As Boolean, Optional ByVal theSQl As String) As Byte
'*****************************
'Author Paul Horsley
'Date 2001-12-18
'time : 14:22
' ****************************
' function has 5 parameters
' 0 = the string name of the report to print
' 1 = lstclients = a listbox
' 2 = the calling form
' 3 = AllowPrint = should print or preview
' 4 = the sql string to use // Optional
' ****************************
' Function will return a long indicating print results
' 0 = All done OK
' > 0 the VBA error code. use raise back at calling function to get description.
'
'*****************************
On Error GoTo Print_Err

Dim intCount, iCurrentItem, svar As Integer
Dim strfilter, TMPAccount, stDocName, ExpAccount As String
Dim vntItem As Variant
Dim dbmyDB As Database
Dim DocLoop As Document
'SQL STRINGS AVAILABLE
Dim myA4Sql As String
Dim myexportSql As String
Dim mysql As String
' The final sql string to use as record source in whatever report you ahve made.
' You have three sql string being made all the time for you
' in the reports table record you assign a numeric 1,2,3 to the sqltype field and
' this will be used for passing one of the sql's made here into the final sql string >> local variable strRecordSourceSql
' The strRecordSourceSql will be used to set the reocrd source of the report.
Dim strRecordSourceSql As String
Dim iResult As Long
iResult = 0
Dim repExists As Boolean

'old stuff not needed but maybe you have a use?
If IsEmpty(theSQl) Then
iResult = 1
'GoTo Print_exit
End If

Set dbmyDB = CurrentDb
With dbmyDB.Containers!Reports
For Each DocLoop In .Documents
If DocLoop.Name = TheReportNameToPrint Then
repExists = True
Exit For
End If
Next DocLoop
End With
'set object to nothing - good house cleaning + free mem
Set dbmyDB = Nothing

If Not repExists Then
MsgBox "The requested report " & TheReportNameToPrint & " is not available in this version of Consol2000," & vbCr & "contact support and inform them.", vbOKOnly + vbInformation, "Missing report"
iResult = 0
GoTo Print_exit
End If

intCount = LstClients.ItemsSelected.Count - 1

If intCount = -1 Then
MsgBox "To create a report you must first choose an EDI-CON client batch from the list provided.", vbOKOnly + vbInformation, "No batch selected"
LstClients.Requery
frm.frmReports.Value = 0
Exit Function
Else
If intCount = 0 Then
For Each vntItem In LstClients.ItemsSelected
strfilter = strfilter & "((([010-calculations_archive].repSource)=" & _
"'" & LstClients.ItemData(vntItem) & "'" & "))" & " OR " '"
Next
If strfilter <> "" Then
strfilter = Left(strfilter, Len(strfilter) - 4)
LstClients.Requery
mysql = "SELECT [010-calculations_archive].* FROM [010-calculations_archive] WHERE " & strfilter & ";"
myexportSql = "SELECT [010-calculations_archive].* INTO TmpConExp FROM [010-calculations_archive] WHERE " & strfilter & ";"
myA4Sql = "SELECT [010-calculations_archive].repSource , [010-calculations_archive].ISEU FROM [010-calculations_archive] GROUP BY [010-calculations_archive].repSource , [010-calculations_archive].ISEU HAVING " & strfilter & ";"
Else
MsgBox "No items selected", vbOKOnly
LstClients.Requery
frm.frmReports.Value = 0
Exit Function
End If
Else
For Each vntItem In LstClients.ItemsSelected
strfilter = strfilter & "([010-calculations_archive].repSource)=" & _
"'" & LstClients.ItemData(vntItem) & "'" & " OR "
Next
If strfilter <> "" Then
strfilter = Left(strfilter, Len(strfilter) - 4) & ")"
myexportSql = "SELECT [010-calculations_archive].* INTO TmpConExp FROM [010-calculations_archive] WHERE ((" & strfilter & ");"
mysql = "SELECT [010-calculations_archive].* FROM [010-calculations_archive] WHERE ((" & strfilter & ");"
myA4Sql = "SELECT [010-calculations_archive].repSource ,[010-calculations_archive].ISEU FROM [010-calculations_archive] GROUP BY [010-calculations_archive].repSource , [010-calculations_archive].ISEU HAVING ((" & strfilter & ");"
Else
MsgBox "No items selected", vbOKOnly
LstClients.Requery
frm.frmReports.Value = 0
Exit Function
End If
End If
End If

'use the GetSqlType function to return the sqltype from the reports record in question.
Select Case GetSqlType(Prefix & TheReportNameToPrint)
Case 1
strRecordSourceSql = mysql
Case 2
strRecordSourceSql = myexportSql
Case 3
strRecordSourceSql = myA4Sql
Case Else
'if not found or > than 1 the function will exit garcefully ( no error given as we assign 0 to function as result )
iResult = 0
GoTo Print_exit
End Select
'set string vars to "" - free mem
mysql = ""
myexportSql = ""
myA4Sql = ""

'This outershell is used to find out if we should strRecordSourceSql
If GetSqlUsage(Prefix & TheReportNameToPrint) = 1 Then
' Use the documents container to grab the report we need.
' you can not use any other method as only open reports are seen in the reports collection
' To get passed this I used the documents container of the object dbmydb, and assigned
' the contianer as !Reports - works great!!!
Set dbmyDB = CurrentDb
With dbmyDB.Containers!Reports
For Each DocLoop In .Documents
If DocLoop.Name = TheReportNameToPrint Then
DoCmd.Echo False, "Creating " & DocLoop.Name & "report - please wait."
DoCmd.OpenReport DocLoop.Name, acViewDesign
Reports(DocLoop.Name).RecordSource = strRecordSourceSql
DoCmd.Close acReport, DocLoop.Name, acSaveYes
DoCmd.Echo True
Exit For
End If
Next DocLoop
End With
'set object to nothing - good house cleaning + free mem
Set dbmyDB = Nothing
End If
' finally we see if the param passed indicates to print or to show preview ' Slick!!!
If AllowPrint Then
DoCmd.OpenReport TheReportNameToPrint, acNormal
Else
DoCmd.OpenReport TheReportNameToPrint, acPreview
End If

Print_exit:
' first pass off the iresult value to the function, then exit
PrintReport = iResult
Exit Function

Print_Err:
'here you can make your own error capture descisions
Select Case Err.number
Case 0
Case Else
iResult = Err.number
End Select
Resume Print_exit

End Function

'************************ END CODE SNIPPET

hope this helps, cheers Paul








Svara

Nyligen

  • 08:28 Butiksskyltar: Hur upplever utbude
  • 22:31 Slappna av
  • 19:55 kick-off med fokus på hälsa?
  • 19:53 kick-off med fokus på hälsa?
  • 16:24 Föreslå en skönhetsklinik online
  • 16:23 Föreslå en skönhetsklinik online
  • 18:42 Hvor finder man håndlavede lamper
  • 18:41 Hvor finder man håndlavede lamper

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 570 770
27 960
271 761
552
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies