New record

awrude

Registered User.
Local time
Yesterday, 19:36
Joined
May 23, 2013
Messages
18
I am having issues with going to a new record and i do not know why. I am thinking it should be straightforward. I have a startup form with 5 buttons on it. One of them opens up a diferent form and is 'supposed to' open a blank record so the user can enter in their info. It currently goes to the last record and thats it.

If gintNew = 0 Then
'DoCmd.GoToRecord , , acNewRec
cmdAddNew.Visible = True
Call cmdAddNew_Click
cmdAddNew.Visible = False
' rst.MoveLast
'rst.MoveNext
'rst.NewRecord
cmdSaveExit.Visible = True
End If

as you can see I have tried .addnew, .movelast and .movenext, and docmd.gotorecord. I set my RST before this step. I have even tried moving it to after this step for the gotorecord

the gotorecord said it wasnt available at this time
I have even tried creating a button through the wizard and tried activating it through VBA but nothing is working. Am i on the right track?
 
I don't think this is all the code.
Please post your entire code for this.

Dale
 
the only other code that i have that would effect this is:

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * from Weekly")

If gintNew = 0 Then
'DoCmd.GoToRecord , , acNewRec
cmdAddNew.Visible = True
Call cmdAddNew_Click
cmdAddNew.Visible = False
' rst.MoveLast
'rst.MoveNext
'rst.NewRecord
cmdSaveExit.Visible = True
End If

set rst = nothing
 
I don't see why you need to open a recordset to go to a new record.
Is "gintNew" a text box on your form?

Also when opening a recordset you should close the recordset with a .Close.

Is the underlying data for this form a query or table.
If query, is the query updateable?

Dale
 
I have a startup form that has 5 buttons on it. Each makes a different button on the second visible. I set the gIntNew in the onclick of a button on the first form. I didnt think i would have to open the recordset to add a new record. I tried the docmd.gotorecord,,acnewrec but it gives me an error. The data is all from a table. I totally forgot about .close. Its been awhile since i have worked with VBA. Thanks for the help
 
...I set the gIntNew in the onclick of a button on the first form.../QUOTE]

My guess is that gintNew is never equal to 0.

What type of Field is gint?

How, exactly, are you setting the gIntNew?

What code is used to open the second Form?

Where, exactly, are you using the code you posted?

Linq ;0)>
 
gintNew is a global integer. I have it set up on the startup form. When the user clicks the 'New Record' button, it sets gintNew to 0. It then opens the second for and closes the first.

gstrNew = 0
DoCmd.OpenForm "weekly1"
Me.SetFocus
DoCmd.Close

i have the first code i postedde in the form_load of the second form
 
I do not know what happened it is now telling me also i cannot set my other controls at this time. It was working, then it quit. not sure why
 
gintNew is a global integer. I have it set up on the startup form. When the user clicks the 'New Record' button, it sets gintNew to 0. It then opens the second for and closes the first.

gstrNew = 0

DoCmd.OpenForm "weekly1"
Me.SetFocus
DoCmd.Close
Well, if this is your actual code, your problem is obvious! You're setting gstrNew to Zero, not gintNew, which is what you're checking for in the code in the secondary Form!

Linq ;0)>
 
i just went through it. I have it all set up as gstrNew. Its still doing the same thing. Thank you for that though
 
i just went through it. I have it all set up as gstrNew. Its still doing the same thing. Thank you for that though

Still doing what 'same thing," not going to a new record or demonstrating your new problem?

I suspect that you're going to have to attach a Zipped up copy of your File, saved in 2007 format (2003 format would be even better) if we're going to be able to unravel this for you.

An explanation, giving the particular Form names, as well as the Command Button name, will also help.

Linq ;0)>
 
I agree with linq that a copy of your database would be helpful in investigating the issue.
I would also suggest you tell us WHAT you are trying to do in plain English. In my view you have shown us How you have done something. Once we understand What you are trying to do, there may be several options.

I'm really not following the rationale for the global, or the other form for that matter.
 
Here it is. I was working on it in Access 2010 to begin with. I took it home and worked on it using my 2007 and it has given me quite a bit of grief since. It starts off as a startup screen. If you click drive around report it will print off a report, so you may ot want to do that. From their any of the other buttons should open up the second screen. Hopefully you can see what i am trying to do. Some parts may look messy or strange, i appologize, i havent used vba in quite a while
 

Attachments

Users who are viewing this thread

Back
Top Bottom