Quantcast
Channel: Access for Developers forum
Viewing all 14673 articles
Browse latest View live

not a valid path

$
0
0

Hi I'm getting the below.

'O:\MVP_be.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

the thing is that is not the right file name or path.  it should be going in the network

Network\server\data\mvp_database\gatelog-local.mdb

it should be looking for "gatelog-local.mdb" and not "MVP_be.mdb"

How can I fix this?  Also I'm using microsoft runtime 2016.



Help with SQL query

$
0
0

My SQL query skills have improved, but I am stumped as to how to go about setting up this query.  Any help is appreciated.

I have 3 tables.  A skeleton of their structure is:

Table 1: Artist
id (auto-increment)
Name (string)

Table 2: Album
id (auto-increment)
Name (string)
Artist_id (index to id in Artist)

Table 3: Collection
id (auto-increment)
DateAdded (Date/Time)
Album_id (index to Album_id)

The Artist table is a database of all known artists.  The Album table is a list of all known albums from said artists.  The Collection table represents albums held in a a collection.

I would like a query that performs the following.  "For any Artist for which at least one Album exists in Collection, return a result in the form:

Artist
Album
DateAdded (where this field is the DateAdded from Collection or null if it does not exist in Collection)

I am looking for an output in which ALL albums appear in the output for which at least one album is in the collection for a given artist.

Example.

Artist

1 Chicago
2. Beach Boys
3 Beatles

Albums

1 ChicagoIX 1
2 ChicagoXXX 1
3 ChicagoIV 1
4 Abbey Road 3
5 The White Album 3
6 Endless Summer 2

Collection

1 1/1/2001  1
2 1/2/2001 4



Desired Output

Artist          Album       Date Added
Chicago      Chicago IX     1/1/2001
Chicago      Chicago XXX    null
Chicago      Chicago IV     null
Beatles      Abbey Road     1/2/2001
Beatles      The White Album   null

Key points to note:

1.  The Beach Boys do not show up in the output as no albums by them are in the collection

2.  All albums by artists for which at least one album is in the collection appear in the output, with the DateAdded field either populated (if in Collection) or null (if not).


Want to sort the output to a XML file using VBA

$
0
0

Hi

I have data in a temp table and can export it to a XML-file. Everything run just great, but not the sorting of the output to XML-file.

This line of code works in its content of other code rows:

orderBodyQuery = "SELECT distinct DesignationOfOrigin, BodyRecordUniqueReference, ExciseProductCode, CnCode, Quantity, NetWeight, AlcoholicStrength, DegreePlato,  FROM " + mainTable + " WHERE [" + uniqOrderColumn + "] = """ + Order + """"

I can’t figure out how to sort the output. This is what I want:

I want is to have the orderBodyQuery sorting the data by content in “BodyRecordUniqueReference”, ascending order.

Any ideas?


Cheers // Peter Forss Stockholm

Herramienta de eliminación de software malintencionado de Windows, agosto de 2018 (KB890830)

$
0
0

Herramienta de eliminación de software malintencionado de Windows, agosto de 2018 (KB890830)   me sale error

Executable access file (accde) doesn't run vba script

$
0
0

Hi

I wanted to create an accde file that runs vba scripts but it doesn't work.Is there a way to do it?I don't want to let the users modify the structure of the database.

Thank you in advance

Adam


MS Access SQL Query taking forever to run

$
0
0

Hi Folks -

I have a SQL Query that is taking forever to run. Even if I do "SELECT TOP 5", it takes a VERY long time.

Both of the tables I'm query are both linked. Does anyone have any ideas as to why?

SELECT 
  dbo_Tak_Tempo_activities_vw.[ActEmpFTE]
 , dbo_Tak_Tempo_activities_vw.[ActEmpId]
 , dbo_Tak_Tempo_activities_vw.[ActEmpLoc]
 , dbo_Tak_Tempo_activities_vw.[ActEmpMgr]
 , dbo_Tak_Tempo_activities_vw.[ActEmpName]
 , dbo_Tak_Tempo_activities_vw.[ActEmpPos]
 , dbo_Tak_Tempo_activities_vw.[ActEmpTaskCode]
 , dbo_Tak_Tempo_activities_vw.[ActEMpTaskName]
 , dbo_Tak_Tempo_activities_vw.[ActivityCode]
 , dbo_Tak_Tempo_activities_vw.[ActPercentTimevalue]
 , dbo_Tak_Tempo_activities_vw.[CompanyCode]
 , dbo_Tak_Tempo_activities_vw.[DepartmentName]
 , dbo_Tak_Tempo_activities_vw.[PersonnelSubArea]
 , dbo_Tak_Tempo_activities_vw.[FunctionalArea]
 , dbo_Tak_Tempo_activities_vw.[CostCenter]
 , Project_portfolio.[PF_TherapeuticArea] AS [TA]
 , dbo_Tak_Tempo_activities_vw.[ActPrjCode]
 , dbo_Tak_Tempo_activities_vw.[ActPrjName]
 , dbo_Tak_Tempo_activities_vw.[ActPrjType]
 , dbo_Tak_Tempo_activities_vw.[ActProgram]
 , dbo_Tak_Tempo_activities_vw.[ActProgramInitiative]
 , dbo_Tak_Tempo_activities_vw.[ActTaskCode]
 , dbo_Tak_Tempo_activities_vw.[ActTimevalue]
 , dbo_Tak_Tempo_activities_vw.[ActWeekBeginDate]
 , dbo_Tak_Tempo_activities_vw.[ActDescription]
FROM dbo_Tak_Tempo_activities_vw LEFT JOIN Project_portfolio ON dbo_Tak_Tempo_activities_vw.[ActTaskCode] = Project_portfolio.[Name];

Thank you!

like in excel Transpose...

$
0
0

I want a ATable that was transposed from BTable in Access..

i think it's possible  but I can't

 

from 2010....it's not working

$
0
0

Private Sub UserForm_Initialize()
    Dim i As Single

    Listbox1.ColumnCount = 3
'This list box contains 3 data columns

    'Load integer values MyArray
    For i = 0 To 5
        MyArray(i, 0) = i
        MyArray(i, 1) = Rnd
        MyArray(i, 2) = Rnd
    Next i

    'Load ListBox1
    Listbox1.list() = MyArray   ' <-  the problem is here

End Sub


Need Help Creating a Record from Relational Tables

$
0
0

Hello,

I am creating a database for my team to keep track of their skills and competencies. All members of the team are measured on a set number of competencies and skills/levels. 

I have created 3 tables. 

1-Names of Candidates

2- Competency Type

3- Skills- Each competency has its own skills and levels 

Now, each candidate will have the same template of competency and skills to fillout. The only change would be the completion % of candidates for each skill. 

How do I first combine all the tables to create a standard record set for each candidate. And how do I then give candidates the ability to individually update records based on the progress they make in improving their skills.

String will not save leading zeros.

$
0
0

Im totally confused by this because I created a function to randomly generate a number with "n" digits and whatever string is contained in "x". 

Private Function GenKeyInt(n As Integer, x As String)
    Dim RandGen As String
    Dim RandGenAdd As String

    Do While n >= 1
    n = n - 1
    RandGenAdd = Int((9 - 0 + 1) * Rnd() + 0)
    RandGen = [RandGen] + [RandGenAdd]
    Loop

    RandGen = [RandGen] + [x]
    GenKeyInt = RandGen
    MsgBox RandGen

End Function

So as it is, calling the function

y = GenKey.GenKeyInt(4,4)

I get a random 4 digit number combined with 4.  Problem occurs if I want x to be 00004.  I still get a random number but still ending with 4 instead of 00004.

How do I get VB to stop dropping leading zeros?



VBA using SQL EXISTS() to check if a record exists in a table.

$
0
0

My code is kinda jacked, but I was attempting to use an SQL string to give a variable "x" a true or false value based on whether a record exists or not.

I stumbled across the EXISTS() statement, never used it but tried to get it to work.  I failed.

Private Function CheckEntry1()

    Dim sSQL As String
    Dim x As String
    
    sSQL = "EXISTS(SELECT * FROM tblCloud.IDCloud WHERE tblCloud.[IDCloud] = '000000001');"
    x = DoCmd.RunSQL(sSQL)
    MsgBox (x)

End Function

So I need to be able to look up whether a value exists in a field and if it does I need a yay or nay answer.  I would like to use SQL for speed. 

I can't figure out this run-time error -2147217904 (80040e10) No value given for one or more required parameters help me to overcome it im a beginner

$
0
0
Option Compare Database
Option Explicit
Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim Status As String
Dim Image As Office.FileDialog
Dim ImagePath As Variant
Dim ImageName As String

Private Sub cboCategory_GotFocus()
    cboCategory.Dropdown
End Sub

Private Sub cmdEdit_Click()
'    cmdNew.Enabled = False
    cmdSave.Enabled = True
    cmdEdit.Enabled = False
    Status = "Old"
    txtTitle.SetFocus
End Sub

Private Sub cmdLocationInfo_Click()
    DoCmd.OpenForm "frmLocationInfo", acNormal
End Sub

'Private Sub cmdNew_Click()
'    Call clear(Me)
'    txtID.Value = AutoNumberReturn("tbBook", "BookID")
'    txtTitle.SetFocus
'    cmdSave.Enabled = True
'    cmdNew.Enabled = False
'    Status = "New"
'End Sub

Private Sub cmdSave_Click()
    Dim rs1 As New ADODB.Recordset
    Dim cn1 As New ADODB.Connection
    Dim sqledit As String
    If cn1.State = adStateOpen Then cn1.Close
    Set cn1 = CurrentProject.AccessConnection
'______________________________________________________________
    If IsNull(cboLocationID.Value) Then
        MsgBox "Please Choose Location", vbInformation, "Information"
        cmdSave.Enabled = True
    Else
        If rs1.State = adStateOpen Then rs1.Close
        sqledit = "Select * From tbBook Where BookID=" & txtID.Value
        With rs1
            .CursorType = adOpenDynamic
            .CursorLocation = adUseClient
            .LockType = adLockOptimistic
            .Open sqledit, cn1, , , adCmdText
            rs1(1) = txtBookID.Value
            rs1(2) = txtTittle.Value
            rs1(3) = txtAuthor.Value
            rs1(4) = cboCategory.Value
            rs1(5) = txtYear.Value
            rs1(6) = cboISBN.Value
            rs1(7) = ImageName
            .Update
            .Close
        End With
    cboCategory.Requery
    MsgBox "Edit Completed", vbInformation, "Save"
    Call Form_Load
    End If
End Sub


Private Sub Form_Load()
    Dim sql As String
'    cmdNew.Enabled = True
    cmdEdit.Enabled = False
    cmdSave.Enabled = False
    If cn.State = adStateOpen Then cn.Close
    Set cn = CurrentProject.AccessConnection
    If rs.State = adStateOpen Then rs.Close
    With rs
        sql = "select * from tbBook Order by BookID"
        .CursorType = adOpenDynamic
        .CursorLocation = adUseClient
        .LockType = adLockOptimistic
        .Open sql, cn, , , adCmdText
    End With
    Set lstBook.Recordset = rs
End Sub


Private Sub Image45_Click()
    txtSearch.SetFocus
End Sub

Private Sub imgCover_Click()
    Set Image = Application.FileDialog(msoFileDialogFilePicker)
    With Image
        .Title = "Select Image"
        .Filters.clear
        .AllowMultiSelect = False
        .Filters.ADD "All File", "*.**"
        .Filters.ADD "JPG File", "*.jpg*"
        .Filters.ADD "PNG File", "*.png*"
        .Filters.ADD "JEPG File", "*.jepg*"
        If .Show = True Then
           For Each ImagePath In .SelectedItems
               ImageName = ImagePath
               imgCover.Picture = ImageName
           Next
        End If
    End With
End Sub

Private Sub lstBook_Click()
    With lstBook
        txtID.Value = .Column(0)
        txtTitle.Value = .Column(1)
        txtAuthor.Value = .Column(2)
        txtYear.Value = .Column(3)
        cboCategory.Value = .Column(4)
        txtISBN.Value = .Column(5)
        cboLocationID.Value = .Column(6)
        imgCover.Picture = .Column(7)
    End With
    cmdEdit.Enabled = True
End Sub

Private Sub txtSearch_KeyUp(KeyCode As Integer, Shift As Integer)
    Dim records As New ADODB.Recordset
    Dim connects As New ADODB.Connection
    Dim sqls As String, sts As String
    If connects.State = adStateOpen Then connects.Close
    Set connects = CurrentProject.AccessConnection
    If records.State = adStateOpen Then records.Close
    sts = "'%" & txtSearch.Text & "%'"
    sqls = "Select * from tbBook Where Title Like " & sts & "order by BookID"
    With records
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Open sqls, connects, , , adCmdText
    End With
    Set lstBook.Recordset = records
    lstBook.Selected(0) = True
    Call lstBook_Click
End Sub

MS Acces - Pass Through Query + Local Query

$
0
0

Hi Folks -

I have a pass through query that works as expected pulling in 500K rows from MSSQL table.

Then, I am writing a local query (using the pass through query as a table) as there is a  Column in the local DB (MS Access) I need to LEFT JOIN on.  The pass through query runs in seconds however when I build the latter query, LEFT JOINing a local column on it, its takes FOREVER AND EVER.

Is there a way to speed this up?

Thanks!

access sql - extract recordset with id x cli and article with recordset max data

$
0
0

solved with: 

  WHERE T1.DATE = T2.DATE 

instead of:

  WHERE T1.ID_movimag = T2.ID_movimag 

Thank you v.m.

An access query on a db SQL 

id, client, article, data ...
1    1         x         10/2
2    1         x          20/2
3    1         y          11/2
4    1         y          21/2
5    2         x          12/2
6    2         x          22/2

I need only the records of each client and anrticle which have the major date:

2    1    x     20/2

4    1    y     21/2

6    2    x     22/2
The Query:
SELECT T1.ID_movimag, T1.CLI_FOR, T1.ARTICOLO, T1.DATA
 FROM DB2_MOVIMAG AS T1
   WHERE (SELECT COUNT (*)
                  FROM DB2_MOVIMAG AS T2
                  WHERE T1.ID_movimag = T2.ID_movimag 
                  AND T2.DATA > T1.DATA)=0;
But it gives all 6 records of all dates

Anybody can help me?


Access 2010 Startup Form removed

$
0
0

My Access 2010 database has a startup form which initiates datacomm with an external scale.  Four times in the last 6 months, when I started the database, the form didn't start.  When I investigated, the startup form in options/currentdb/Display Form was '(none)'.  I have no idea how that was getting changed.  Would I be safer using an OpenForm command in the autoexec macro? Any thoughts on how the Display Form is being reset?


Run-time error '3061'; Too few parameters, expected 2

$
0
0


I thought I had it figured out...

Please tell me what's wrong with the code below. Both temp!vars are good and they show up fine in the message box.

        Dim sqlJMJ As String
        Dim rsJMJ As DAO.Recordset
        MsgBox "JMJ; " & "MachID=" & [TempVars]![MachID] & ", JobID=" & [TempVars]![JobID] & ", MatQtyOnMach=" & _
        [TempVars]![MatQtyOnMach] & ", MatLotID=" & [TempVars]![MatLotID]
        sqlJMJ = "SELECT * FROM [Job-MachineJoint] WHERE [MachID] = TempVars!MachID AND [JobID] = TempVars!JobID ;"
        Set rsJMJ = CurrentDb.OpenRecordset(sqlJMJ)
        On Error GoTo ErrHandlerJMJ

        With rsJMJ

            If Not .BOF And Not .EOF Then
                .MoveLast
TryEditAgainJMJ:
                    .Edit
                    ![FinishDate] = Date
                    ![Finished] = 1
                    ![MatLeftOver] = TempVars!MatQtyOnMach - Forms!MachineJobFinishMoveMatBack!MatLeftOnMach
                    ![LastMatLotID] = TempVars!MatLotID
                    .Update
            End If
           .Close
        End With
        Set rsJMJ = Nothing


I do not get the "clean" email address from the control on the Form

$
0
0

Hi

I want to catch an email adress from a Form.

but I do not get the "clean" email address.

Dim receiver As String

receiver = Forms![Beställningar av råvaror och insatsvaror Beverages].[epost].Column(1)

debug.Print receiver
verkauf@dkf-linck.de#mailto:verkauf@dkf-linck.de#

What am I doing wrong?



Cheers // Peter Forss Stockholm

Seeking best practice advice - converting VB to VBA or SQL query?

$
0
0

Hi Folks -

I"m moving a lot of my processes into an MS Access data. Once of them being a process I currently use a combination of batch and vb script.

The process is as follows:

1. Export MSSQL using batch script (sqlcmd)

2. Transform file using vb script

The question I have is around some of the VB transformation, particularly this part:

objWorkbook1.Worksheets(FILE1TAB).Range("Y1").Value = "=" & _"IF(LEFT(K1,3)=""AUT"",""10000000""&O1," & _"IF(LEFT(K1,3)=""BEL"",""10000000""&O1," & _"IF(LEFT(K1,3)=""BRA"",""1000000""&O1," & _"IF(LEFT(K1,3)=""CHE"",""10000000""&O1," & _"IF(LEFT(K1,3)=""CHN"",""100000""&O1," & _"IF(LEFT(K1,3)=""DEU"",""10000000""&O1," & _"IF(LEFT(K1,3)=""DNK"",""10000000""&O1," & _"IF(AND(LEFT(K1,2)=""EU"",LEN(O1)=6),""10000000""&O1," & _"IF(AND(LEFT(K1,2)=""EU"",LEN(O1)=3),""CA010000000""&O1," & _"IF(AND(LEFT(K1,2)=""EU"",LEN(O1)=4),""CA01000000""&O1," & _"IF(AND(LEFT(K1,2)=""EU"",LEN(O1)=10),""1000""&O1," & _"IF(AND(LEFT(K1,3)=""GBR"",LEN(O1)=3),""CA010000000""&O1," & _"IF(AND(LEFT(K1,3)=""GBR"",LEN(O1)=10),""1000""&O1," & _"IF(AND(LEFT(K1,3)=""JPN"",LEN(O1)=8),""JP0000""&O1," & _"IF(AND(LEFT(K1,3)=""ITA"",LEN(O1)=6),""10000000""&O1," & _"IF(AND(LEFT(K1,3)=""JPN"",LEN(O1)=7),""JP00000""&O1," & _"IF(AND(LEFT(K1,3)=""JPN"",LEN(O1)=6),""JP000000""&O1," & _"IF(AND(LEFT(K1,10)=""JPTP001CMC"",LEN(O1)=6),""JP000000""&O1," & _"IF(AND(LEFT(K1,10)=""JPTP001CMC"",LEN(O1)=8),""JP0000""&O1," & _"IF(AND(LEFT(K1,10)=""JPTP001GMS"",LEN(O1)=8),""JP0000""&O1," & _"IF(AND(LEFT(K1,10)=""JPTP001PRD"",LEN(O1)=8),""JP0000""&O1," & _"IF(AND(LEFT(K1,10)=""JPTP001TPC"",LEN(O1)=6),""JP000000""&O1," & _"IF(AND(LEFT(K1,10)=""JPTP001TPC"",LEN(O1)=7),""JP00000""&O1," & _"IF(AND(LEFT(K1,3)=""KOR"",LEN(O1)=7),""1000000""&O1," & _"IF(AND(LEFT(K1,3)=""NOR"",LEN(O1)=6),""10000000""&O1," & _"IF(AND(K1=""NULL"",OR(LEN(O1)={7,8})),""JP""&TEXT(O1,""000000000000"")," & _"IF(AND(K1=""NULL"",O1<>""NULL"",LEN(O1)=4),""CA01000000""&O1," & _"IF(AND(K1=""NULL"",O1<>""NULL"",LEN(O1)=6),""10000000""&O1," & _"IF(AND(K1=""NULL"",O1<>""NULL"",LEN(O1)<>7,LEN(O1)<>8,LEN(O1)<>6),""ERROR : Cost Center Not Mapped - Contact Support""," & _"IF(AND(K1=""NULL"",O1=""NULL""),""""," & _"IF(AND(LEFT(K1,2)=""SG"",LEN(O1)=3),""CA010000000""&O1," & _"IF(AND(LEFT(K1,6)=""Takeda"",LEN(O1)=6),""10000000""&O1," & _"IF(AND(LEFT(K1,3)=""TDC"",LEN(O1)=8),""JP0000""&O1," & _"IF(AND(LEFT(K1,3)=""TCH"",LEN(O1)=8),""JP0000""&O1," & _"IF(AND(LEFT(K1,2)=""US"",LEN(O1)=6),""CA010000""&O1," & _"IF(AND(LEFT(K1,2)=""US"",LEN(O1)=4),""CA01000000""&O1," & _"""ERROR : Not Mapped or no CC defined - Contact Support""))))))))))))))))))))))))))))))))))))"

How would suggest I go about doing that transformation in the MS Access DB? Thank you!

32 bit windows controls not in references.

$
0
0

Ok I hope I get this right. I have an old version of Access 2007 I think. I have used Office 365 Access to modify and clean up the code I also added a label to one of the forms. The issue is when I take the code back to the PC( an old laptop 32 bit, Win 10) where it is currently running I get a missing reference for Win Common Ctrls. It is looking for the 64 bit OCX file in wowsys64. I cannot get Office to keep the 32 bit reference file as it always reverts back to the 64 bit ver.  It appears this is also causing other issues such as the VBA LEFT function not being recognized. So I hope this makes some sense. 

Thanks in advance.

TheLimoCat

Turn SELECT into UPDATE statement

$
0
0

Hi Folks -

Doing some testing and finally seeing the result I want to see using SELECT statement. However now I need to update the table and having trouble creating the update statement.  Here is my SELECT statement:

SELECT
	ROUND(([Global_Monthly_Headcount].[Scheduled Weekly Hours] / [Global_Monthly_Headcount_FTE_Mapping].[FTE]), 2) AS [FTE]
FROM [Global_Monthly_Headcount] INNER JOIN [Global_Monthly_Headcount_FTE_Mapping]
ON [Global_Monthly_Headcount].[Cost Center - ID] = [Global_Monthly_Headcount_FTE_Mapping].[Country];

I've tried this will no luck:

UPDATE [Global_Monthly_Headcount]
   SET [Global_Monthly_Headcount].[FTE] = ROUND(([Global_Monthly_Headcount].[Scheduled Weekly Hours] / [Global_Monthly_Headcount_FTE_Mapping].[FTE]), 2)
  FROM [Global_Monthly_Headcount], [Global_Monthly_Headcount_FTE_Mapping]
 WHERE [Global_Monthly_Headcount].[Cost Center - ID] = [Global_Monthly_Headcount_FTE_Mapping].[Country];

Any help is appreciated - thank you!


Viewing all 14673 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>