473,386 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

SetFocus Doesnt Seem to be Working.

Private Sub SupplierSKUCode_AfterUpdate()
If Nz(DLookup("SupplierSKUCode", "tblProduct", "SupplierSKUCode='" & _
Me.SupplierSKUCode & "'"), "zzzz") <> "zzzz" Then MsgBox "SupplierSKUCode Already Exist.", vbCritical

If MsgBox("Duplicate Record." _
& vbCrLf & vbCrLf & "Do you want to have Duplicate Record?" _
, vbYesNo, "Changes Made...") = vbYes Then
Me.ProductDescription.SetFocus
Else
Me.SupplierSKUCode.SetFocus
DoCmd.RunCommand acCmdUndo
Me.SupplierSKUCode.SetFocus
End If
'Test if control contains text
If IsNull(Screen.ActiveControl) = False Then
'convert text to Proper Case
Screen.ActiveControl = StrConv(Screen.ActiveControl, vbUpperCase)
End If
End Sub

The set focus doesnt seem to work, please help me whats wrong with my coding..tnx
Apr 26 '07 #1
10 2336
MMcCarthy
14,534 Expert Mod 8TB
Private Sub SupplierSKUCode_AfterUpdate()
If Nz(DLookup("SupplierSKUCode", "tblProduct", "SupplierSKUCode='" & _
Me.SupplierSKUCode & "'"), "zzzz") <> "zzzz" Then MsgBox "SupplierSKUCode Already Exist.", vbCritical

If MsgBox("Duplicate Record." _
& vbCrLf & vbCrLf & "Do you want to have Duplicate Record?" _
, vbYesNo, "Changes Made...") = vbYes Then
Me.ProductDescription.SetFocus
Else
Me.SupplierSKUCode.SetFocus
DoCmd.RunCommand acCmdUndo
Me.SupplierSKUCode.SetFocus
End If
'Test if control contains text
If IsNull(Screen.ActiveControl) = False Then
'convert text to Proper Case
Screen.ActiveControl = StrConv(Screen.ActiveControl, vbUpperCase)
End If
End Sub

The set focus doesnt seem to work, please help me whats wrong with my coding..tnx
Why are you setting the focus?
Apr 26 '07 #2
Re: SetFocus Doesnt Seem to be Working.
Quote:
Originally Posted by rockdc1981
Private Sub SupplierSKUCode_AfterUpdate()
If Nz(DLookup("SupplierSKUCode", "tblProduct", "SupplierSKUCode='" & _
Me.SupplierSKUCode & "'"), "zzzz") <> "zzzz" Then MsgBox "SupplierSKUCode Already Exist.", vbCritical

If MsgBox("Duplicate Record." _
& vbCrLf & vbCrLf & "Do you want to have Duplicate Record?" _
, vbYesNo, "Changes Made...") = vbYes Then
Me.ProductDescription.SetFocus
Else
Me.SupplierSKUCode.SetFocus
DoCmd.RunCommand acCmdUndo
Me.SupplierSKUCode.SetFocus
End If
'Test if control contains text
If IsNull(Screen.ActiveControl) = False Then
'convert text to Proper Case
Screen.ActiveControl = StrConv(Screen.ActiveControl, vbUpperCase)
End If
End Sub

The set focus doesnt seem to work, please help me whats wrong with my coding..tnx


Why are you setting the focus?


If user selects No from the prompt Undo command will clear the form but my cursor is on the next field,
Apr 26 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. Private Sub SupplierSKUCode_AfterUpdate()
  2.     If Nz(DLookup("SupplierSKUCode", "tblProduct", "SupplierSKUCode='" & _
  3.     Me.SupplierSKUCode & "'"), "zzzz") <> "zzzz" Then MsgBox "SupplierSKUCode Already Exist.", vbCritical
  4.  
  5.    If MsgBox("Duplicate Record." _
  6.     & vbCrLf & vbCrLf & "Do you want to have Duplicate Record?" _
  7.     , vbYesNo, "Changes Made...") = vbYes Then
  8.       Me.ProductDescription.SetFocus
  9.    Else
  10.       DoCmd.RunCommand acCmdUndo
  11.       Me.Requery ' if that doesn't work try Me.Refresh
  12.       Me.SupplierSKUCode.SetFocus
  13.    End If
  14.  
  15.    'Test if control contains text
  16.    If IsNull(Screen.ActiveControl) = False Then
  17.       'convert text to Proper Case
  18.       Screen.ActiveControl = StrConv(Screen.ActiveControl, vbUpperCase)
  19.    End If
  20. End Sub
  21.  
Apr 26 '07 #4
Expand|Select|Wrap|Line Numbers
  1. Private Sub SupplierSKUCode_AfterUpdate()
  2.     If Nz(DLookup("SupplierSKUCode", "tblProduct", "SupplierSKUCode='" & _
  3.     Me.SupplierSKUCode & "'"), "zzzz") <> "zzzz" Then MsgBox "SupplierSKUCode Already Exist.", vbCritical
  4.  
  5.    If MsgBox("Duplicate Record." _
  6.     & vbCrLf & vbCrLf & "Do you want to have Duplicate Record?" _
  7.     , vbYesNo, "Changes Made...") = vbYes Then
  8.       Me.ProductDescription.SetFocus
  9.    Else
  10.       DoCmd.RunCommand acCmdUndo
  11.       Me.Requery ' if that doesn't work try Me.Refresh
  12.       Me.SupplierSKUCode.SetFocus
  13.    End If
  14.  
  15.    'Test if control contains text
  16.    If IsNull(Screen.ActiveControl) = False Then
  17.       'convert text to Proper Case
  18.       Screen.ActiveControl = StrConv(Screen.ActiveControl, vbUpperCase)
  19.    End If
  20. End Sub
  21.  

Me.Requery sets me back to the first record...Me.Refresh doesnt work at all, the focus gets to the next field...cant think of any otherwise...but really i appreciate your help...any more ideas will be valued...
Apr 27 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. Private Sub SupplierSKUCode_AfterUpdate()
  2.     If Nz(DLookup("SupplierSKUCode", "tblProduct", "SupplierSKUCode='" & _
  3.     Me.SupplierSKUCode & "'"), "zzzz") <> "zzzz" Then MsgBox "SupplierSKUCode Already Exist.", vbCritical
  4.  
  5.    If MsgBox("Duplicate Record." _
  6.     & vbCrLf & vbCrLf & "Do you want to have Duplicate Record?" _
  7.     , vbYesNo, "Changes Made...") = vbYes Then
  8.       Me.ProductDescription.SetFocus
  9.    Else
  10.       DoCmd.RunCommand acCmdUndo
  11.       Me.ProductDescription.SetFocus
  12.       Me.SupplierSKUCode.SetFocus
  13.    End If
  14.  
  15.    'Test if control contains text
  16.    If IsNull(Screen.ActiveControl) = False Then
  17.       'convert text to Proper Case
  18.       Screen.ActiveControl = StrConv(Screen.ActiveControl, vbUpperCase)
  19.    End If
  20. End Sub
  21.  
Apr 27 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
I had a bright idea, try this ...
Expand|Select|Wrap|Line Numbers
  1. Private Sub SupplierSKUCode_AfterUpdate()
  2. Dim ctlName As String
  3.  
  4.     If Nz(DLookup("SupplierSKUCode", "tblProduct", "SupplierSKUCode='" & _
  5.     Me.SupplierSKUCode & "'"), "zzzz") <> "zzzz" Then MsgBox "SupplierSKUCode Already Exist.", vbCritical
  6.  
  7.    If MsgBox("Duplicate Record." _
  8.     & vbCrLf & vbCrLf & "Do you want to have Duplicate Record?" _
  9.     , vbYesNo, "Changes Made...") = vbYes Then
  10.      ctlName = "ProductDescription"
  11.    Else
  12.       DoCmd.RunCommand acCmdUndo
  13.      ctlName = "SupplierSKUCode"
  14.    End If
  15.  
  16.    'Test if control contains text
  17.    If Not IsNull(Me(ctlName)) Then
  18.       'convert text to Proper Case
  19.      Me(ctlName) = StrConv(Me(ctlName), vbUpperCase)
  20.    End If
  21. End Sub
  22.  
Apr 27 '07 #7
i tried setting the focus to other field...it worked after the undo command..i just dont get it...SupplierSkuCode is properly spelled but it wont set focus after all.



Im really glad THESCRIPTS exist...u guys are great!
Apr 27 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
i tried setting the focus to other field...it worked after the undo command..i just dont get it...SupplierSkuCode is properly spelled but it wont set focus after all.



Im really glad THESCRIPTS exist...u guys are great!
You're welcome. Did you try my last suggestion?
Apr 27 '07 #9
Hooray!!!!this code worked! Thanks very much!God Bless and More power!




Private Sub SupplierSKUCode_AfterUpdate()
If Nz(DLookup("SupplierSKUCode", "tblProduct", "SupplierSKUCode='" & _
Me.SupplierSKUCode & "'"), "zzzz") <> "zzzz" Then MsgBox "SupplierSKUCode Already Exist.", vbCritical

If MsgBox("Duplicate Record." _
& vbCrLf & vbCrLf & "Do you want to have Duplicate Record?" _
, vbYesNo, "Changes Made...") = vbYes Then
Me.ProductDescription.SetFocus
Else
DoCmd.RunCommand acCmdUndo
Me.ProductDescription.SetFocus
Me.SupplierSKUCode.SetFocus
End If

'Test if control contains text
If IsNull(Screen.ActiveControl) = False Then
'convert text to Proper Case
Screen.ActiveControl = StrConv(Screen.ActiveControl, vbUpperCase)
End If
End Sub
Apr 27 '07 #10
hi mary or anybody in here,

is it possible that the duplicate record message box wont appear if the SKU code doesnt exist...it bothers me coz everytime i have a new record the second "If" appears ask me vbyesno...ty



Private Sub SupplierSKUCode_AfterUpdate()
If Nz(DLookup("SupplierSKUCode", "tblProduct", "SupplierSKUCode='" & _
Me.SupplierSKUCode & "'"), "zzzz") <> "zzzz" Then MsgBox "SupplierSKUCode Already Exist.", vbCritical

If MsgBox("Duplicate Record." _
& vbCrLf & vbCrLf & "Do you want to have Duplicate Record?" _
, vbYesNo, "Changes Made...") = vbYes Then
Me.ProductDescription.SetFocus
Else
DoCmd.RunCommand acCmdUndo
Me.ProductDescription.SetFocus
Me.SupplierSKUCode.SetFocus
End If

'Test if control contains text
If IsNull(Screen.ActiveControl) = False Then
'convert text to Proper Case
Screen.ActiveControl = StrConv(Screen.ActiveControl, vbUpperCase)
End If
End Sub[/quote]
May 3 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: amy | last post by:
I have a text box, after user input the value, a validate function trigered. if the value is invalid, alert display, and also set focus back to this control. The alert displays, but when the...
4
by: Mad Scientist Jr | last post by:
i am trying to set focus to a specific control depending on the outcome of a validator control and it is not working. none of these methods are working to setfocus: 1....
8
by: Shachar | last post by:
Hi All, I need to start a new process calc for example and when ever the user click on the button the application should setfocus to the calc application. I use this code but it is NOT...
2
by: Gil | last post by:
can you set focus to the current access application through vba? lets say i tell access to open another application and that new application gains the focus and causes access to loose the focus....
5
agroover
by: agroover | last post by:
I can't seem to figure out how to get rid of the errors. I recieve the following error when I leave the Grade.SetFocus in my code... Microsoft Access can't move the focus to the control Grade ...
7
by: Hong | last post by:
Hi I have a main form with 7 subforms where the master/child link is the RefID in the main form where the Main form is 1-many relationship to those subforms. All the subform have the same...
9
by: rockdc1981 | last post by:
please help me with my code, any revisions is appreciated... Private Sub Combo42_LostFocus() Dim Result Dim Msg Dim cr As String cr = Chr$(13) Result = Me.Combo42 If IsNull(Result)...
8
by: OldBirdman | last post by:
This should be so, so simple I hesitate to ask. I have a Form named "fNavButtons" used as a SubForm in control named "subformNavButtons". subformNavButtons is a control on my main form named...
3
by: ckrows | last post by:
I have a main form with a button that makes a subform visible. I added a button in the form footer of the subform that is supposed to hide the subform. This does not work because the focus is on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.