VBA 2105

  • Thread starter Prath via AccessMonster.com
  • Start date
P

Prath via AccessMonster.com

Hello,
I have a problem with error 2105.
In table, I don't have primary key.
Can u help me, pls.

The problem:
I entered a code into cod_int. I'll look in the article table designation etc.
....
When I have lots of code, it displays the first item and n'insert not the
second article. It puts the error message 2105

Function Ajout_Article() As Boolean
Dim RstEan As Recordset, crit_ean As String
Dim eco As Recordset
Set db = CurrentDb
If cod_int <> "" Then
If Not IsNumeric(cod_int) Then
Call MsgBox("Vous ne pouvez saisir que des codes barres ou des
codes articles dans cette zone!", vbExclamation)
Let cod_int = ""
cod_int.SetFocus
Let Ajout_Article = False
Else

Set RstEan = db.OpenRecordset("SELECT EAN_INT.cod_int, EAN_INT.cod_ean,
ARTICLES.lib_int, ARTICLES.cod_tva, ARTICLES.lib_nbe, ARTICLES.pri_vte_ht
FROM ARTICLES, EAN_INT WHERE EAN_INT.cod_int = ARTICLES.cod_int")

If cod_int >= 10000000 Then
crit_ean = " [cod_ean] = " & cod_int
Else
crit_ean = " [cod_int] = '" & cod_int & "'"
End If
RstEan.FindFirst crit_ean

If RstEan.NoMatch Then
Let Ajout_Article = False
Else
If cod_int >= 10000000 Then
Let cod_int = RstEan!cod_int
End If
Let lib_int = RstEan!lib_int
Let pri_vte_ht = RstEan!pri_vte_ht
Let cod_tva = RstEan!cod_tva
Let lib_nbe = RstEan!lib_nbe
Let Quantite = 1
Let Stot_HT = pri_vte_ht * Quantite
Calc
Quantite.SetFocus
Let Ajout_Article = True
End If
RstEan.Close
End If
Else
Call MsgBox("Vous devez saisir un code barres ou un code article dans
cette zone!", vbExclamation, "Article inconnu!")
cod_int.SetFocus
Let Ajout_Article = False
End If

'VERIFICATION D ECO CONTRIBUTION ATH
code_article = cod_int
Set eco = db.OpenRecordset("SELECT count(*) as nb FROM PLA_ARTLIE WHERE
pla_artlie.int_art=" & code_article & " ")

If eco!nb >= 1 Then
eco_contribution
Else
coef = 0
End If
eco.Close
'RstEan.Close
End Function
'-----------------------------------------------------------------------------
-------------------------------------
Private Sub eco_contribution()
Dim eco As Recordset
Dim eco1 As Recordset
Dim RstEan As Recordset
Dim record() As String
Set db = CurrentDb
Dim code_int As String
Dim crit_ean As String
Dim i As Integer
Dim data As Variant
Dim Err_cmdSuivant_Click As Variant
DoCmd.GoToRecord , , acNext
Set eco = db.OpenRecordset("SELECT count(*) as nb FROM PLA_ARTLIE WHERE
pla_artlie.int_art=" & code_article & " ")
'POUR NB = 1
If eco!nb = 1 Then
Set eco1 = db.OpenRecordset("select art_lie, coef_lie from pla_artlie
where int_art=" & code_article & " ")
'Quantite = eco1!art_lie
Let cod_int = eco1!art_lie
coef = eco1!coef_lie
'Quantite_LostFocus


Set RstEan = db.OpenRecordset("SELECT EAN_INT.cod_int, EAN_INT.cod_ean,
ARTICLES.lib_int, ARTICLES.cod_tva, ARTICLES.lib_nbe, ARTICLES.pri_vte_ht
FROM ARTICLES, EAN_INT WHERE EAN_INT.cod_int = ARTICLES.cod_int")

Let cod_int = RstEan!cod_int
Let lib_int = RstEan!lib_int
Let pri_vte_ht = RstEan!pri_vte_ht
Let cod_tva = RstEan!cod_tva
Let lib_nbe = RstEan!lib_nbe
Let Quantite = 1
Let Stot_HT = pri_vte_ht * Quantite
Calc
Quantite.SetFocus
'Let Ajout_Article = True
RstEan.Close

End If
 
P

Prath via AccessMonster.com

Prath said:
Hello,
I have a problem with error 2105.
In table, I don't have primary key.
Can u help me, pls.

The problem:
I entered a code into cod_int. I'll look in the article table designation etc.
....
When I have lots of code, it displays the first item and n'insert not the
second article. It puts the error message 2105

Function Ajout_Article() As Boolean
Dim RstEan As Recordset, crit_ean As String
Dim eco As Recordset
Set db = CurrentDb
If cod_int <> "" Then
If Not IsNumeric(cod_int) Then
Call MsgBox("Vous ne pouvez saisir que des codes barres ou des
codes articles dans cette zone!", vbExclamation)
Let cod_int = ""
cod_int.SetFocus
Let Ajout_Article = False
Else

Set RstEan = db.OpenRecordset("SELECT EAN_INT.cod_int, EAN_INT.cod_ean,
ARTICLES.lib_int, ARTICLES.cod_tva, ARTICLES.lib_nbe, ARTICLES.pri_vte_ht
FROM ARTICLES, EAN_INT WHERE EAN_INT.cod_int = ARTICLES.cod_int")

If cod_int >= 10000000 Then
crit_ean = " [cod_ean] = " & cod_int
Else
crit_ean = " [cod_int] = '" & cod_int & "'"
End If
RstEan.FindFirst crit_ean

If RstEan.NoMatch Then
Let Ajout_Article = False
Else
If cod_int >= 10000000 Then
Let cod_int = RstEan!cod_int
End If
Let lib_int = RstEan!lib_int
Let pri_vte_ht = RstEan!pri_vte_ht
Let cod_tva = RstEan!cod_tva
Let lib_nbe = RstEan!lib_nbe
Let Quantite = 1
Let Stot_HT = pri_vte_ht * Quantite
Calc
Quantite.SetFocus
Let Ajout_Article = True
End If
RstEan.Close
End If
Else
Call MsgBox("Vous devez saisir un code barres ou un code article dans
cette zone!", vbExclamation, "Article inconnu!")
cod_int.SetFocus
Let Ajout_Article = False
End If

'VERIFICATION D ECO CONTRIBUTION ATH
code_article = cod_int
Set eco = db.OpenRecordset("SELECT count(*) as nb FROM PLA_ARTLIE WHERE
pla_artlie.int_art=" & code_article & " ")

If eco!nb >= 1 Then
eco_contribution
Else
coef = 0
End If
eco.Close
'RstEan.Close
End Function
'-----------------------------------------------------------------------------
-------------------------------------
Private Sub eco_contribution()
Dim eco As Recordset
Dim eco1 As Recordset
Dim RstEan As Recordset
Dim record() As String
Set db = CurrentDb
Dim code_int As String
Dim crit_ean As String
Dim i As Integer
Dim data As Variant
Dim Err_cmdSuivant_Click As Variant
DoCmd.GoToRecord , , acNext
Set eco = db.OpenRecordset("SELECT count(*) as nb FROM PLA_ARTLIE WHERE
pla_artlie.int_art=" & code_article & " ")
'POUR NB = 1
If eco!nb = 1 Then
Set eco1 = db.OpenRecordset("select art_lie, coef_lie from pla_artlie
where int_art=" & code_article & " ")
'Quantite = eco1!art_lie
Let cod_int = eco1!art_lie
coef = eco1!coef_lie
'Quantite_LostFocus


Set RstEan = db.OpenRecordset("SELECT EAN_INT.cod_int, EAN_INT.cod_ean,
ARTICLES.lib_int, ARTICLES.cod_tva, ARTICLES.lib_nbe, ARTICLES.pri_vte_ht
FROM ARTICLES, EAN_INT WHERE EAN_INT.cod_int = ARTICLES.cod_int")

Let cod_int = RstEan!cod_int
Let lib_int = RstEan!lib_int
Let pri_vte_ht = RstEan!pri_vte_ht
Let cod_tva = RstEan!cod_tva
Let lib_nbe = RstEan!lib_nbe
Let Quantite = 1
Let Stot_HT = pri_vte_ht * Quantite
Calc
Quantite.SetFocus
'Let Ajout_Article = True
RstEan.Close

End If


The data is inserted into the table with RETAIL
id AutoNumber primary key
num_fac int with double
cod_int text with double
lib_int text with double
lib_nbe text with double
pri_vte_ht money with Double
cod_tva int with double
int quantity with double
stot_ht money with Double
 
P

Prath via AccessMonster.com

Prath said:
Hello,
I have a problem with error 2105.
[quoted text clipped - 112 lines]

The data is inserted into the table with RETAIL
id AutoNumber primary key
num_fac int with double
cod_int text with double
lib_int text with double
lib_nbe text with double
pri_vte_ht money with Double
cod_tva int with double
int quantity with double
stot_ht money with Double

DoCmd.GoToRecord , , acNext -> ERROR 2105
 
T

Tom van Stiphout

On Thu, 24 Dec 2009 09:15:09 GMT, "Prath via AccessMonster.com"

I stopped reading after line 3 of your message. EVERY table needs a
PK. Often they also need additional unique indexes, required fields,
foreign keys etc. to create a good database design.
You want to cut off one arm and then ask us how to play the piano.
Sorry bro, shouldn't have cut off your arm.
Fix your db design; then let's see if the problems evaporate.

-Tom.
Microsoft Access MVP

Hello,
I have a problem with error 2105.
In table, I don't have primary key.
Can u help me, pls.

The problem:
I entered a code into cod_int. I'll look in the article table designation etc.
...
When I have lots of code, it displays the first item and n'insert not the
second article. It puts the error message 2105

Function Ajout_Article() As Boolean
Dim RstEan As Recordset, crit_ean As String
Dim eco As Recordset
Set db = CurrentDb
If cod_int <> "" Then
If Not IsNumeric(cod_int) Then
Call MsgBox("Vous ne pouvez saisir que des codes barres ou des
codes articles dans cette zone!", vbExclamation)
Let cod_int = ""
cod_int.SetFocus
Let Ajout_Article = False
Else

Set RstEan = db.OpenRecordset("SELECT EAN_INT.cod_int, EAN_INT.cod_ean,
ARTICLES.lib_int, ARTICLES.cod_tva, ARTICLES.lib_nbe, ARTICLES.pri_vte_ht
FROM ARTICLES, EAN_INT WHERE EAN_INT.cod_int = ARTICLES.cod_int")

If cod_int >= 10000000 Then
crit_ean = " [cod_ean] = " & cod_int
Else
crit_ean = " [cod_int] = '" & cod_int & "'"
End If
RstEan.FindFirst crit_ean

If RstEan.NoMatch Then
Let Ajout_Article = False
Else
If cod_int >= 10000000 Then
Let cod_int = RstEan!cod_int
End If
Let lib_int = RstEan!lib_int
Let pri_vte_ht = RstEan!pri_vte_ht
Let cod_tva = RstEan!cod_tva
Let lib_nbe = RstEan!lib_nbe
Let Quantite = 1
Let Stot_HT = pri_vte_ht * Quantite
Calc
Quantite.SetFocus
Let Ajout_Article = True
End If
RstEan.Close
End If
Else
Call MsgBox("Vous devez saisir un code barres ou un code article dans
cette zone!", vbExclamation, "Article inconnu!")
cod_int.SetFocus
Let Ajout_Article = False
End If

'VERIFICATION D ECO CONTRIBUTION ATH
code_article = cod_int
Set eco = db.OpenRecordset("SELECT count(*) as nb FROM PLA_ARTLIE WHERE
pla_artlie.int_art=" & code_article & " ")

If eco!nb >= 1 Then
eco_contribution
Else
coef = 0
End If
eco.Close
'RstEan.Close
End Function
'-----------------------------------------------------------------------------
-------------------------------------
Private Sub eco_contribution()
Dim eco As Recordset
Dim eco1 As Recordset
Dim RstEan As Recordset
Dim record() As String
Set db = CurrentDb
Dim code_int As String
Dim crit_ean As String
Dim i As Integer
Dim data As Variant
Dim Err_cmdSuivant_Click As Variant
DoCmd.GoToRecord , , acNext
Set eco = db.OpenRecordset("SELECT count(*) as nb FROM PLA_ARTLIE WHERE
pla_artlie.int_art=" & code_article & " ")
'POUR NB = 1
If eco!nb = 1 Then
Set eco1 = db.OpenRecordset("select art_lie, coef_lie from pla_artlie
where int_art=" & code_article & " ")
'Quantite = eco1!art_lie
Let cod_int = eco1!art_lie
coef = eco1!coef_lie
'Quantite_LostFocus


Set RstEan = db.OpenRecordset("SELECT EAN_INT.cod_int, EAN_INT.cod_ean,
ARTICLES.lib_int, ARTICLES.cod_tva, ARTICLES.lib_nbe, ARTICLES.pri_vte_ht
FROM ARTICLES, EAN_INT WHERE EAN_INT.cod_int = ARTICLES.cod_int")

Let cod_int = RstEan!cod_int
Let lib_int = RstEan!lib_int
Let pri_vte_ht = RstEan!pri_vte_ht
Let cod_tva = RstEan!cod_tva
Let lib_nbe = RstEan!lib_nbe
Let Quantite = 1
Let Stot_HT = pri_vte_ht * Quantite
Calc
Quantite.SetFocus
'Let Ajout_Article = True
RstEan.Close

End If
 
Top