opening a new form at a new record

simonI

Registered User.
Local time
Yesterday, 20:06
Joined
Dec 22, 2005
Messages
25
looking for help again!!

i am trying to switch between 2 forms using a command button..

i have 2 things i am trying to achieve

i want the form to open up at a new record as at the moment it seems to be opening at the last record created.. i have tried to use an open form function for new records but that doesnt seem to work.

secondly i have tried to use the code below to go to the next record then close the form and open a new one...

DoCmd.GoToRecord , , acNewRec
DoCmd.Close
DoCmd.OpenForm ("Welcome Page")


but so far all it does is open the new form it doesnt go on to the new record in the current one!!!


hope it makes sense

cheers

si
 
Try it this way:

Code:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "Welcome"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.Close

Exit_Command1_Click:
    Exit Sub

Err_Command1_Click:
    MsgBox Err.Description
    Resume Exit_Command1_Click
    
End Sub

on the open event in the FORM "Welcome" add this code:

DoCmd.GoToRecord , , acNewRec

Let me know if it works.

Bones
 
thanks bones..

somehow i managed to post this thread twice and someone answered earlier that worked but thanks anyhow...

now i have a similar question. i now realised that sometimes (i.e. when it is not the first time you are accessing the form) i want the form to be accessed at a specific record. the code i am using is below - now i can use the find function but that is a bit cumbersome and unprofessional, so i tried to add an input box that the form then uses as a reference to open the form up at...

Private Sub Form_open(Cancel As Integer)
Dim user As String

msg = "Are you updating for the first time?" ' Define message.
style = vbYesNo ' Define buttons.
title = "Data Validation" ' Define title.
response = MsgBox(msg, style, title)
If response = vbYes Then ' User chose Yes.

DoCmd.GoToRecord , , acNewRec

Else

user = InputBox("Please enter Student ID")

DoCmd.OpenForm , , , "[user]= & Me![StudentID]"


End If


unfortunately i cant get this last bit to work!!

any help people

cheers

si
End Sub
 
zip the file and attach it and I will look at it. You need to create a Query based on a Form.
 
Hi bonecrusher

Could you please post the answer on this board, as I am looking for this solution too.

Cheers
 

Users who are viewing this thread

Back
Top Bottom