Access - Save inputbox value to datasheet (table)

Status
Niet open voor verdere reacties.

PatrickStel

Gebruiker
Lid geworden
20 mei 2015
Berichten
39
Goedemiddag,

Ik zit vast op een probleem, ik heb al verschillende dingen geprobeerd maar kom er niet uit.

Code:
'Pop-up for information where the pv is located and save it to the db
Private Sub Destroyed_pv_Click()
If Me.Destroyed_pv = vbTrue Then
    Dim Strg As String, hyperlink_pv_var$
    Strg = "Typ your location here..."
    Strg = InputBox("Fill in the location of the PV.", "PV Location", Strg)
    If Strg = "" Then
        hyperlink_pv_var$ = "You didn't fill in the box"
    Else
        hyperlink_pv_var$ = "Location of the PV is: " &vbNewLine & Strg
    End If
    MsgBox hyperlink_pv_var$
Else
End If
End Sub

Ik moet de uitkomst van hyperlink_pv_var$ opslaan in mijn datasheet (tabel) ik heb dit al geprobeerd

Code:
DoCmd.RunSQL "INSERT INTO Registratie formulier.PV_Location"_&"(PV_Location) VALUES "_&"(hyperlink_pv_var$);"

Maar dit werkt niet, ik hoop dat jullie mij kunnen helpen.

Groeten,
Patrick
 
Je query ziet er heel vreemd uit. Ik denk dat je zoiets bedoelt:
Code:
    Strg = InputBox("Fill in the location of the PV.", "PV Location", "Typ your location here...")
    If Strg = "" Then
        hyperlink_pv = "You didn't fill in the box."
    Else
        hyperlink_pv = "Location of the PV is: " & Strg
    End If
    CurrentDb.Execute "INSERT INTO [Registratie formulier] ([PV_Location]) VALUES ('" & hyperlink_pv & "') "
 
Klopt dat bedoelde ik inderdaad bedankt daarvoor :).

Hij schrijft nu ook alles netjes weg zoals de bedoeling was alleen nog niet helemaal wat ik wil.

Nu doet hij namelijk het volgende.

Alles van het veld waaronder de checkboxes schrijft hij weg op Bijvoorbeeld regel 900 maar dan schrijft hij de locatie wat je invult in de InputBox weg op regel 901.

Gr,
Patrick
 
Je maakt een nieuw record aan, dus dat lijkt mij logisch :). Dan zou je een bijwerkquery moeten gebruiken.
 
Heb het nu opgelost met een Call functie. :)


Dat is me duidelijk, zal je me hier mee kunnen helpen?

Ik heb op dit moment het volgende
Code:
Private Sub Vernietigd_PV_Click()
If Me.Vernietigd_PV = vbTrue Then
    Dim Strg_PV As String, hyperlink_pv_var$
[B]    
    Call Save_Button_Clock
    Dim inboeknr As String
    inboeknr = Nz(Forms![Registratie formulier]!CustID, "")
    'Message Box for debugging.
    MsgBox inboek nr[/B]
    Strg_PV = "Locatie van het PV"
    Strg_PV = "InputBox("Vul a.u.b. de locatie in van het PV.", "PV Locatie", Strg_PV)
    If Strg_PV = "" Then
        hyperlink_pv_var$ = "Je hebt niks ingevuld!"
    Else
        hyperlink_pv_var$ = "Locatie van het opgegeven pv is:" & vbNewLine & Strg_PV
    End If
    CurrentDb.Execute "INSERT INTO [Registratie formulier] ([PV_Location]) VALUES ('" & Strg_PV & "')"
Else
End If
End Sub

Ik heb het stukje van inboeknr erbij ingezet om te kijken als ik die kan fetchen zodat ik bij een INSERT of UPDATE Query een WHERE kan gebruiken om de gegevens bij de goeie record te plaatsen, alleen lukt het me niet om die te fetchen.

Inboeknr word namelijk opgemaakt in een andere Private Sub;
Code:
Private Sub Save_Button_Click()
On Error GoTo Err_Save_Button_Click

If IsNull (Me![Inboek Nr]) Then
    Me![Inboek Nr] = Format(Nz(Dmax("[Inboek Nr]", "Registratie Formulier", "[YearID]='" & Year(Date) & "'"), 0) +1)
End If
Me! [CustID] = [YearID] & "-" & Format [Inboek Nr], "00000")
        DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_Save_Button_Click:
    Exit Sub

Err_Save_Button_Click:
    MsgBox Err.Description
    Resume Exit_Save_Button_Click
End Sub

Want aan de hand van het uniek inboek nummer kan ik de waarde van PV_Location bij de juiste record plaatsen.

Groeten,
Patrick
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan