DoCmd.GoToRecord , , AcNewRec

i have a listbox that manipulates records on another form but in case i click on one of the records in the listbox that doesnt have any corresponding record in the other form then instead of it saying that it cant locate the record i would like the form to go to a new record....

i've been trying at it but cant get it right...

plz assist... anyone.

View Replies


Docmd.Gotorecord Help

can anyone tell me what wrongwith this and how to make it work properly.

Private Sub LogSheetNumber_LostFocus()
DoCmd.OpenForm "LogSheetFRM", , , , , acHidden
DoCmd.GoToRecord (acDataForm,"LogSheetFrm",acNewRec,)
Forms!LogSheetFrm.LogSheetNumber = Forms!UseageFRM.LogSheetNumber
DoCmd.Close acForm, "LogSheetFRM"
End Sub


View Replies View Related

DoCmd.GoToRecord Help Needed

Hi there

I am making a form that has been set up to have a number of tabs so I can have more then 1 page on the form.

One of the tab pages is used as a search form.There is a couple of textboxes and a listbox where the results end up
What I am trying to do is have a double click set up on the listbox so I can double click the result I want and have the forms ID goto that record.

Its a bound form. The primary key is called PersonalID and its bound to a txtbox called txtPersonalID.

this is my code but its not working

Private Sub lstSearchResults_DblClick(Cancel As Integer)

Dim strPersonalID As String
strPersonalID = Me.lstSearchResults.Column(0)
DoCmd.GoToRecord acActiveDataObject, "PersonalID", acGoTo, strPersonalID
DoCmd.GoToControl "pgePersonalInformation"

End Sub

When I try run the code I get an error 2489. saying The object 'PersonalID' isn't open.

What am I doing wrong?

Can anyone help out


View Replies View Related

Docmd.gotorecord Failing - Version: 2002 (10.0) XP

In my popup form I have:
intVendID = me.VendID
DoCmd.RunCommand acCmdSaveRecord
intCurrRecord = DCount("[unitID]", "qryStoreVendorUnits", "[unitVenID] = " intVendID
DoCmd.Close acForm, "frmStoreVendorUnitAddEdit
DoCmd.GoToRecord , "frmStoreVendorUnit", CurrRecord
The last line Docmd.GotoRecord generates an error: The object 'frmStoreVendorUnit' isn't open. But I can see the form is open. I'm assuming that the Docmd.Close will close my popup form and then the focus is transfered back to frmStoreVendorUnit followed by the execution of the docmd.gotorecord (display the record just added)? But apparrently not. What am I doing wrong here? Thx All!

View Replies View Related

DoCmd.GoToRecord , , AcLast Causes Db To Hang (err 2486) - Version: 2000 (9.0)

I apologise if this seems involved, but let me set the scene. My database is based around reviews, each of which can have a number of actions which, in turn can have any number of progress notes. In addition, each review can also have a number of report_updates. Data is contained in tblReviews, tblActions, tbl Progress and tblReports. Each table has it's own PK and I have established the following one to many relationships:

tblReviews to tblActions
tblActions to tblProgress
tblReviews to tblReports

FormA contains a list of all reviews with a button to open FormB using the following code:

DoCmd.OpenForm "FormB", , , "[Review_Ref]=" & Me.Review_Ref

FormB (datasource is tblActions) contains two subforms (based respectively on tblProgess and tblReports) with customer navigation buttons to move between records (actions), changing the record on the progres subform as necessary. All works well except that when I try to move to the last record (using the code below) I get the eror message number 2486 saying "You can't carry out this action at the present time".

DoCmd.GoToRecord , , acLast

I should mention the code works, in that the last record is displayed, but I get the error message when I try to do anything else (use any other Control Button or Close the form).

I've scoured the net and this problems seems to be a right ******, so any help would be much appreciated.


View Replies View Related

"DoCmd.GoToRecord , , A_NEWREC " What Action Will Be Taken When This Stmt Executed


could you please tell me what action will be happned when this both statement executed..

DoCmd.GoToRecord , , A_NEWREC
SendKeys "%N", True

Form ahse defines these statement as well.

Option Compare Database
Option Explicit

View Replies View Related

Lockup Using "docmd.gotorecord Acform, "MergeInput2", Acnewrecor - Version: 2002 (10.0) XP

Im having an intermitant problem when creating new records to my data base. I'm building a list of future records to put into the table in my form. When the user clicks submit, the code pulls the information from this list and most of the time produces the correct records. in a do...loop I have it create a new record and I then assign the values to it. On the next loop it creates another and it's a repeated process. Sometime it works without any problems doing all records, but sometimes it locks up at the newrecord line. I've tried doing the new record with VBA and by using a macro. Sometimes it passes and sometimes it doesn't. Is there a way I can keep this from happening.

View Replies View Related

Display Existing Record In AcNewRec Routine - Version: 2000 (9.0)

I have a membership database in which new records can be added by pressing an 'Add New Record' button (this activates acNewRec).

Due to the fact that old records can be deleted it is sometimes necessary to manually type the membership number rather than using the auto-incremented value.

Everything works fine except when the number that has been manually entered already exists. In this case what I want to be able to do is to display the existing record (without using filtering) and to cancel the 'Add New Record" action.

I've done a lot of 'googling' but can't seem to find the answer ...



View Replies View Related

AcNewRec--replacing Record Info Not Adding A New - Version: 2000 (9.0)

I have a popup form that starts a process to add records with specified content based on the user's selection from a combo box. The problem is that there are suppose to be 3 new records added to a "subform" on the main form. Instead, only the last of the 3 is added in the end. If there is already a record filled in then it overwrites that one in the form. When I look at the data table for that subform, only the 3rd item has been added.

Here is the code that I am using on the AfterUpdate event of the combo box on the popup form. Do you see something that I am missing in the code?

Private Sub txtReferralForBx_AfterUpdate()
If Me.[txtReferralForBx].Value = "Yes" Then
Forms![Patient Demographics]![Care Planner].SetFocus
DoCmd.GoToRecord , , acNewRec
Forms![Patient Demographics]![Care Planner].Form![Care Option].Value = "Biopsy, performed"
DoCmd.GoToRecord , , acNewRec
Forms![Patient Demographics]![Care Planner].Form![Care Option].Value = "Biopsy report received"
DoCmd.GoToRecord , , acNewRec
Forms![Patient Demographics]![Care Planner].Form![Care Option].Value = "Biopsy follow-up"
DoCmd.Close acForm, "frmpopBxWithReferral"

ElseIf Me.[txtReferralForBx].Value = "No" Then
DoCmd.GoToRecord , , acNewRec
Forms![Patient Demographics]![Care Planner]![Care Option].Value = "Referral, no biopsy"
DoCmd.Close acForm, "frmpopBxWithReferral"
End If
End Sub


View Replies View Related

Enhancing Interface And DoCmd.Quit Vs DoCmd.Close - Version: 2000 (9.0)

I would like to know how others handle the users interface (and testing mode) for a situation.

I'm on a mission to give the users an "efficient" interface. (Clean, intuitive, minimal clutter, etc.) And I like uncluttered code - if it doesn't really do anything, remove it.

Inherited an Access file to print Shipping labels, accesses our ERP database.
It has one form with text boxes to collect information and two buttons: Print and Exit.
When they click the [Exit] button the file closes - DoCmd.Quit. When I'm testing I like to change it to DoCmd.Close (This is a new technique for me. I have started doing this on my files that generate reports).

First thought: Do I really need the [Exit] button when the [Close] box will suffice. What are your thoughts about the pros and cons?

Things aren't going as expected while in "test" mode. I have DoCmd's to .Quit / .Close in both the Exit button sub and Form_Close. When I click to exit (either [Exit] or [Close Box] the file closes - I have to close Access and re-open the file. I've tried different combinations of .Quit and .Close in the two subs, but, can't get a combination to merely stop everything, and leave me with the database objects window in tact.

Here's coding:

Code: Private Sub cbExit_Click() <- Exit button on the form.

On Error Resume Next

Dim lRetVal As Long
lRetVal = Shell("C:Program FilesSeagullBartender 7.10Professionalartend.exe /X")
Me.Visible = False
'Quit when live, Close when testing

End Sub

Code: Private Sub Form_Close()

On Error Resume Next

Dim lRetVal As Long
lRetVal = Shell("C:Program FilesSeagullBartender 7.10Professionalartend.exe /X")
Me.Visible = False

'Quit when live, Close when testing

End Sub

Help. :-)

View Replies View Related

How To Process The Result Of A Docmd.openquery Or Docmd.runsql C - Version: 2003 (11.0)

I would like to select rows from tables be either using the docmd.openquery or docmd.runsql command.

I know how to perform this part of the puzzle, but how do I set up my code to process the result of this command?

I need to be able to capture data and later update it


View Replies View Related

DoCmd.Close Versus Unload (also Qs About DoCmd In General) - Version: 2007 (12.0)

Hello again fellow forumers,

It’s been a little over a week since I last picked up Access and VBA and I’m happy to report that I’m progressing quite nicely.

My only concern is a fear of becoming overly dependent on the functions/macros/actions (forgive the incorrect terminology) that are exclusive to MS Access 2007. Since I have no prior VB programming experience and am new to Windows IDEs, I am not able to immediately differentiate between what some might call ‘vanilla’ VB functions/code and functions that work only in Access. Furthermore, the (slight?) differences between VBA, VB6, and VB.NET do confuse me a little.

This is important for me because I am aiming for portability of code. I’ll get specific. Let’s start with this ‘DoCmd’ thing. Is this ‘DoCmd’ part of VBA or just Access-only? All I know is that I’ve been using ‘DoCmd’ for opening and closing forms, primarily. I’ve been learning from the Help file without any other reference, and it seems to encourage the use of ‘DoCmd’ for just about everything. As far as I understand it, ‘DoCmd’ and the ‘domain functions’ (plus a good lot of other stuff I’m sure) isn’t available outside of VBA or access. What then, are the VB equivalents for these actions? (Not all, just DoCmd.openform and DoCmd.close to begin with)

So my question for today, really… is just “How do I close and open forms without the use of ‘DoCmd’?” In addition, what are the main differences between using say, ‘DoCmd.openform’ and ‘Load’?

I have tried using ‘Load’ and ‘Unload’ but I am having problems with the syntax.
The statement I am trying to replace is:

DoCmd.Close acForm, "MainMenu", acSaveNo

I have tried:

Unload MainMenu
Unload “MainMenu”
Unload forms(“MainMenu”)


None of them work, which is to say they produce an error message of one kind or another.
I now turn to this forum for very much appreciated pointers.
And thanks for your patience!

View Replies View Related

GoToRecord New

I'm having trouble getting my subform to go to new record from a main form.

How would I go about making a command button(new record) on a main form link to a subform.

Example: After clicking on command button I would like my main form and subform to go to new record.


View Replies View Related

GoToRecord Procedure

I have the following code in my VB:

DoCmd.GoToRecord , [Response Tasks], acGoTo = [Response_ID], "08"

This is not working however.... The table name is Response Tasks, the Column name is Response_ID and I am trying to pull the info from the one named "08". What am I doing wrong in the procedure?

Thanks in advance

View Replies View Related

Gotorecord Subform

Hi All,

I have a subform in which users kan edit a field. Some contain more than 100 records. After 'an edit' the code save the adjustments in the table. Then the subform automatically jumps to the first record, but I want it to go to the previous record which they just edited. Is that possible? Here's the code so far:

Private Sub Afgehandeld_Click()
If Afgehandeld.Value = 0 Then
AfgDatum.Value = Null
DoCmd.OpenForm "formulier5"
End If
End Sub

View Replies View Related

GoToRecord Problem!!

Hi there I currently have a DB with a ton of records. What I want to do is have a search box pop up when the user presses a button on the main form. When this search box comes up there is a list box with all the records. The user will then double click a record on the List box and it should appear on the main form. However this is not happenening. Here is my code for the double click in the list box.

Private Sub List3_DblClick(Cancel As Integer)
On Error GoTo Err_List3_DblClick
' Open the info form based on the selection in this listbox.

Dim strFormName As String
strFormName = "complaints"

DoCmd.OpenForm strFormName
DoCmd.GoToRecord , strFormName, acGoTo, " caseid = " & Me![List3] (I think this is where the error is)

DoCmd.Close acForm, "frmLookup"

Exit Sub


Someone please help!!!
MsgBox Err.description
Resume Exit_List3_DblClick
End Sub

View Replies View Related

GOTORECORD On Tab Control?


I have a subform on a tab control. How do I go to the last record of that sub form?

If I use the original form (not as a sub-form), the following code works, but when in the tab control I get an error that "blah blah Form is not open"

Any suggestions? Thanks

Code:DoCmd.GoToRecord acDataForm, "Stock Transfer", acLast'works when main form, but not as subform =/

View Replies View Related

Gotorecord - Version: 2003 (11.0)

i've a module in which i need with a cycle to jump at the next record found by the sequent way:
Dim x As Variant
Dim y As Variant
Dim z As Variant
y = DMin("[Seq]", "ProgImpasti", "Data = Forms![Impasti]![Data]")
z = y + DCount("[Seq]", "ProgImpasti", "Data = Forms![Impasti]![Data]") - 1
DoCmd.GoToRecord acActiveDataObject, , acFirst
For x = y To z
If x < z Then
DoCmd.GoToRecord , , acNext
ElseIf x = z Then Exit For
End If
Next x

My problem is when the next record do not exist, in example i've x=1 and the next x=3, and the module give a run time error 2001
Could someone help me?
How can i resolve this

View Replies View Related

GoToRecord Macro - Version: 2002 (10.0) XP

Is there any way to create a macro that would open a form to the last displayed record?

View Replies View Related

Requery And GoToRecord - Version: 2003 (11.0)

I have a strange issue that I can't figure out why it is happening.

I have a form with a subform. On the main form I have a command button with the following code:

DoCmd.GoToRecord , , acLast

The problem is the Requery works but the GoToRecord doesn't. If I put the GoToRecord code in it's own command button it works fine. So I can click the first button to requery and the second to go to the last record. But why doesn't it work if the code is in the same command button?

View Replies View Related

GotoRecord Syntax - Version: 2002 (10.0) XP

I'm trying to use DoCmd.GoToRecord, , , with a variable to shift focus to the desired record, but I can't seem to get something right. If I replace it with {recordset}.MoveFirst, the focus does shift to the first record in the recordset, so I know I'm getting the correct information into the recordset.

Frequently I need to go to a specific record after hitting EOF for the recordset in a loop, but I'm not sure whether or not that would affect the ability of GoToRecord to get to the right record.

The recordset is derived from a SQL statement:

Set rst = mydb.OpenRecordset(sSql)

sSql is a string derived by search criteria the user entered (Lou's sample search is the basis for this)

I can't figure out the correct way to use the command with a variable (n) to make this work.

DoCmd.GoToRecord , , , n

n is defined as an integer and has the correct value at the point I want to use it.

That doesn't give me any errors or alerts, but it doesn't take me to a different record either.

If someone can point me in the right direction I'd appreciate it.

View Replies View Related

X-treme Newbie Question About GoToRecord

Greetings --

I'm setting up a form to mimic a set of storyboard pages for an educational program. Each page (record) in the storyboard is numbered, and there are navigational branches defined. For example, if the current page is 20, if you click on this icon, you go to 25, another icon 26, another icon 27, and maybe the home icon takes you to storyboard page 1. (The storyboard pages aren't necessarily in record number order.)

I want to put a command button next to the field where I have the branch # defined. Clicking on the button should change the current storyboard page to the branch page number. Maybe this graphic will help explain.

I've been looking at GoToRecord but I think that this will only give me offsets. Or do I need to do a query? Any ideas?



View Replies View Related

OpenForm And GoToRecord Question - Version: 2003 (11.0)

After a bit of trawling through the site, I'm still stumped. Hope you can help.

I have two forms, looking at the same data. FormA is a single form, FormB is a continuous form.

My requirement is to click a command button in FormA, which opens FormB at the currently-selected record in FormA.

The OpenForm event procedure is easy and works fine. The problem I'm having is getting the correct code to go to the current record in FormB.

I don't want to filter formB, I just want to go to the record.

Any help will be appreciated.


View Replies View Related

You Can't Use The GoToRecord Action Or Method... - Version: 2002 (10.0) XP

Hi all.

I want to preface this by saying that I'm a complete newbie at working with VBA, and any help or criticisms you can offer would be much appreciated. Just be gentle .

I'm working on an application for a social service agency that provides holiday meal vouchers good for use at local grocery stores. The funds for the vouchers come out of two different funds and I need to differentiate between those in the data. The first fund has a soft cap (no more certificates are issued after cap is exceeded) of $25,000 and the second fund picks up the overflow. I have an update query that will assign all of the overflow to the second fund, but I need to assign the first fund up to the cap before I can run it. I've written code that I think will work, however I'm getting an error when I try to run it, and I'm not sure why.

The error is Runtime Error '2499': You can't use the GoToRecord action or method on an object in design view. The reason I'm so confused is that the form it refers to isn't open in design view, but in normal view. My code is below, and I've marked the line where it stops. Like I said before, any help is appreciated.


Code: Function setVouchers()

'declare variables for fund total, found flag, and fund full flag
Dim fundTotal As Currency
Dim foundStr As String
Dim fundFull As String

'initialize variables
foundStr = "N"
fundTotal = 0
fundFull = "N"

'transfer adoption information using update queries
DoCmd.OpenQuery "transferAdoptAssist1"
DoCmd.OpenQuery "transferAdoptAssist2"

'open hiddenForm and go to first record
DoCmd.OpenForm "hiddenForm", acNormal, , , , acHidden
DoCmd.GoToRecord , , acFirst 'this is the line where I get the error

'While foundStr = N search for voucherFund 1
Do While foundStr = "Y"
If Forms!hiddenForm.christmasVoucherFund = 1 Then
foundStr = "Y" 'set foundStr flag to Y
fundTotal = SumOfchristmasVoucherAmount 'set fundTotal to existing fund total
Exit Do 'exit inner loop
DoCmd.GoToRecord , , acNext
End If
Exit Do
Loop Until EOF(1)

'close hidden form
DoCmd.Close acForm, "hiddenForm", acSaveYes

'open hidden form 2 and go to first record
DoCmd.OpenForm "hiddenForm2", , , , , acHidden
DoCmd.GoToRecord , , acFirst
Do While Not EOF(1)
If fundTotal < 25000 Then
Forms!hiddenForm2.christmasVoucherFund = 1
fundTotal = fundTotal + Forms!hiddenForm2.christmasVoucherAmount
DoCmd.GoToRecord , , acNext
fundFull = "Y"
Exit Do
End If
Loop While fundFull = "N"
Exit Do

'run update query to assign remaining vouchers to overflow fund
DoCmd.OpenQuery "makeRemainingTSA"

'close hidden form 2
DoCmd.Close acForm, "hiddenForm2", acSaveYes
End Function

View Replies View Related

Do I Use FindFirst Or FindNext Or GoToRecord? - Version: 2003 (11.0)

I have a reports that I'm printing from a list box. On the on click event I've got some code that loops though all the choices in the listbox and prints the right reports. Here's my dilema....

I have to add some code to update the right tables that basically updates the "PrintedReport" field in the table to "yes"...but I don't know if I can use the DoCmd.Findfirst and then use the FindNext or if I should use the GoToRecord command? I guess I'm just not sure how I'm going to loop through the table till that record isn't found either....

I've done something similar but there was only one record in the table that needs updating. I don't know how to do mulitple records.

Any help would be appreciated.

View Replies View Related

How Can I Do A Simple "GoToRecord" In A Form?

I have searched the forum for questions similar to mine, but they all seem more complicated than what I need... and so I am getting a little confused with it all!

I would like to create a "GoToRecord" field in which people can enter a name which then take them to that record (stored in my "ClientName" field) on the Main form...

Can anyone help?


View Replies View Related


I am having issue with running a docmd.openstoredprocedure command in access 2000
DoCmd.OpenStoredProcedure "Proc_tblOpenReworks", acViewNormal
when i click on the cmdButton i get a
runtime error:7874 Microsoft access can't find the object "Proc_tblOpenReworks"
if this helps the cmd is run from a access project
is the and argument or some other way of running this command i would
appr. all the help i can get on this one

View Replies View Related


have searched on above but could not find anything

I want to start another database from within a database from a command button

Use the wizard option for RunApp and it appeared to work okay. definately pointing at the database.

Event procedure is

Private Sub Command39_Click()
On Error GoTo Err_Command39_Click

Dim stAppName As String

stAppName = "msaccess.exe C:LenWorking DatabaseSingle Non Conformance SystemDatabaseSecure Defect Docket Database.mdb"
Call Shell(stAppName, 1)

Exit Sub

MsgBox Err.Description
Resume Exit_Command39_Click

End Sub

Getting error saying that I was trying to use an option in command line that was not recognised.

Few clicks on the OK and the error message cannot find file

Any clues please


View Replies View Related


I have aproblem with the range of this thing. I think I have a wrong synthax or something.

I need to have the first 120 records of columns A and D
The first two lines aren't records but titles

So I had:
DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel8, "ExcelTEMP", mijnFile, False, "A3:A122;D3:D122"

Access tels me there is somthing wrong with the range, though it works in Excel :confused:

View Replies View Related


I've the following SQL query in my database:

DoCmd.RunSQL "INSERT INTO tblPlanner ( RACF, [Date], [Day Capacity], [Role Title], TimeWork ) SELECT tblStaff.RACF, [txtday1] AS Expr1, tblStaff.[Daily Capability], tblStaff.[Role Title], tblStaff.[Contract mins] FROM tblStaff WHERE (((tblStaff.TeamName) Like [txtTeamName])) WITH OWNERACCESS OPTION;"

The problem is everytime it runs it informe that the query will change data in the table. What can I do to stop it?


View Replies View Related

DoCmd Problem In ASP

I am trying to develop a page where users can click on alphabets to look for a company name that starts with the selected letter.
Searching through the forums i came across the method of using DoCmd.

alpha = Request.QueryString("alp")
if alpha <> "" then
DoCmd.ApplyFilter "", "[com_name] Like ""[" & alpha & "]*"""
end if

The 'alpha' variable here holds the alphabet selected by user from another page. However, I'm getting an error message saying

Microsoft VBScript runtime (0x800A01F4)
Variable is undefined: 'DoCmd'

Initially i tried the usual filtering

if alpha <> "" then
rs.Filter = "com_name LIKE " & alpha
end if

The pages are suppose to display records in 10s. But instead of showing only the records of company starting "A" (example) it shows everything.

Please kindly point me to the correct direction to solve this problem.

Thank you so much.


View Replies View Related



I have spent sometime working on sending access reports to customers as asFormatHTML.

Code:DoCmd.SendObject acSendReport, "rptConfirm", acFormatHTML, strEmail, , , "Trade Confirms from Kyte Options " & date, , no, False

Trouble is some of my customers cannot read the attachment! Is it possible to have the message body display a txt of the report/query?

Thanks for any help you can give.

View Replies View Related


I am using the DoCmd.TransferSpreadsheet statement that successfully exports a query result set into excel. I was wondering is there a way to get this result to populate certain fields of an existing excel spreadsheet that I have created and need the information for. Right now the query just creates a new worksheet in the specified workbook.

View Replies View Related

Copyrights 2005-15, All rights reserved